Ignore:
Timestamp:
28/05/2008 16:24:05 (4 years ago)
Author:
chris
Message:

Track and log file deletions by name.

Split crypto init and file sync process into its own method, to reduce
call depth and facilitate calling in process from tests.

Differentiate between 3 uses of stat in BackupClientDirectoryRecord? by
renaming the structures.

Use stat instead of lstat when checking the filesystem that's holding an
entity, in case it's a symbolic link to a different filesystem.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupd/BackupClientDeleteList.cpp

    r217 r2181  
    4343} 
    4444 
    45 // -------------------------------------------------------------------------- 
    46 // 
    47 // Function 
    48 //              Name:    BackupClientDeleteList::AddDirectoryDelete(int64_t) 
     45BackupClientDeleteList::FileToDelete::FileToDelete(int64_t DirectoryID, 
     46        const BackupStoreFilename& rFilename, 
     47        const std::string& rLocalPath) 
     48: mDirectoryID(DirectoryID), 
     49  mFilename(rFilename), 
     50  mLocalPath(rLocalPath) 
     51{ } 
     52 
     53BackupClientDeleteList::DirToDelete::DirToDelete(int64_t ObjectID, 
     54        const std::string& rLocalPath) 
     55: mObjectID(ObjectID), 
     56  mLocalPath(rLocalPath) 
     57{ } 
     58 
     59// -------------------------------------------------------------------------- 
     60// 
     61// Function 
     62//              Name:    BackupClientDeleteList::AddDirectoryDelete(int64_t, 
     63//                       const BackupStoreFilename&) 
    4964//              Purpose: Add a directory to the list of directories to be deleted. 
    5065//              Created: 10/11/03 
    5166// 
    5267// -------------------------------------------------------------------------- 
    53 void BackupClientDeleteList::AddDirectoryDelete(int64_t ObjectID) 
     68void BackupClientDeleteList::AddDirectoryDelete(int64_t ObjectID, 
     69        const std::string& rLocalPath) 
    5470{ 
    5571        // Only add the delete to the list if it's not in the "no delete" set 
    56         if(mDirectoryNoDeleteList.find(ObjectID) == mDirectoryNoDeleteList.end()) 
     72        if(mDirectoryNoDeleteList.find(ObjectID) == 
     73                mDirectoryNoDeleteList.end()) 
    5774        { 
    5875                // Not in the list, so should delete it 
    59                 mDirectoryList.push_back(ObjectID); 
    60         } 
    61 } 
    62  
    63  
    64 // -------------------------------------------------------------------------- 
    65 // 
    66 // Function 
    67 //              Name:    BackupClientDeleteList::AddFileDelete(int64_t, BackupStoreFilenameClear &) 
     76                mDirectoryList.push_back(DirToDelete(ObjectID, rLocalPath)); 
     77        } 
     78} 
     79 
     80 
     81// -------------------------------------------------------------------------- 
     82// 
     83// Function 
     84//              Name:    BackupClientDeleteList::AddFileDelete(int64_t, 
     85//                       const BackupStoreFilename &) 
    6886//              Purpose:  
    6987//              Created: 10/11/03 
    7088// 
    7189// -------------------------------------------------------------------------- 
    72 void BackupClientDeleteList::AddFileDelete(int64_t DirectoryID, const BackupStoreFilename &rFilename) 
     90void BackupClientDeleteList::AddFileDelete(int64_t DirectoryID, 
     91        const BackupStoreFilename &rFilename, const std::string& rLocalPath) 
    7392{ 
    7493        // Try to find it in the no delete list 
    75         std::vector<std::pair<int64_t, BackupStoreFilename> >::iterator delEntry(mFileNoDeleteList.begin()); 
     94        std::vector<std::pair<int64_t, BackupStoreFilename> >::iterator 
     95                delEntry(mFileNoDeleteList.begin()); 
    7696        while(delEntry != mFileNoDeleteList.end()) 
    7797        { 
    78                 if((delEntry)->first == DirectoryID && (delEntry)->second == rFilename) 
     98                if((delEntry)->first == DirectoryID  
     99                        && (delEntry)->second == rFilename) 
    79100                { 
    80101                        // Found! 
     
    87108        if(delEntry == mFileNoDeleteList.end()) 
    88109        { 
    89                 mFileList.push_back(std::pair<int64_t, BackupStoreFilename>(DirectoryID, rFilename)); 
     110                mFileList.push_back(FileToDelete(DirectoryID, rFilename, 
     111                        rLocalPath)); 
    90112        } 
    91113} 
     
    114136         
    115137        // Do the deletes 
    116         for(std::vector<int64_t>::iterator i(mDirectoryList.begin()); i != mDirectoryList.end(); ++i) 
    117         { 
    118                 connection.QueryDeleteDirectory(*i); 
     138        for(std::vector<DirToDelete>::iterator i(mDirectoryList.begin()); 
     139                i != mDirectoryList.end(); ++i) 
     140        { 
     141                connection.QueryDeleteDirectory(i->mObjectID); 
     142                rContext.GetProgressNotifier().NotifyDirectoryDeleted( 
     143                        i->mObjectID, i->mLocalPath); 
    119144        } 
    120145         
     
    123148         
    124149        // Delete the files 
    125         for(std::vector<std::pair<int64_t, BackupStoreFilename> >::iterator i(mFileList.begin()); i != mFileList.end(); ++i) 
    126         { 
    127                 connection.QueryDeleteFile(i->first, i->second); 
     150        for(std::vector<FileToDelete>::iterator i(mFileList.begin()); 
     151                i != mFileList.end(); ++i) 
     152        { 
     153                connection.QueryDeleteFile(i->mDirectoryID, i->mFilename); 
     154                rContext.GetProgressNotifier().NotifyFileDeleted( 
     155                        i->mDirectoryID, i->mLocalPath); 
    128156        } 
    129157} 
     
    141169{ 
    142170        // First of all, is it in the delete vector? 
    143         std::vector<int64_t>::iterator delEntry(std::find(mDirectoryList.begin(), mDirectoryList.end(), ObjectID)); 
     171        std::vector<DirToDelete>::iterator delEntry(mDirectoryList.begin()); 
     172        for(; delEntry != mDirectoryList.end(); delEntry++) 
     173        { 
     174                if(delEntry->mObjectID == ObjectID) 
     175                { 
     176                        // Found! 
     177                        break; 
     178                } 
     179        } 
    144180        if(delEntry != mDirectoryList.end()) 
    145181        { 
     
    149185        else 
    150186        { 
    151                 // Haven't been asked to delete it yet, put it in the no delete list 
     187                // Haven't been asked to delete it yet, put it in the 
     188                // no delete list 
    152189                mDirectoryNoDeleteList.insert(ObjectID); 
    153190        } 
     
    163200// 
    164201// -------------------------------------------------------------------------- 
    165 void BackupClientDeleteList::StopFileDeletion(int64_t DirectoryID, const BackupStoreFilename &rFilename) 
     202void BackupClientDeleteList::StopFileDeletion(int64_t DirectoryID, 
     203        const BackupStoreFilename &rFilename) 
    166204{ 
    167205        // Find this in the delete list 
    168         std::vector<std::pair<int64_t, BackupStoreFilename> >::iterator delEntry(mFileList.begin()); 
     206        std::vector<FileToDelete>::iterator delEntry(mFileList.begin()); 
    169207        while(delEntry != mFileList.end()) 
    170208        { 
    171                 if((delEntry)->first == DirectoryID && (delEntry)->second == rFilename) 
     209                if(delEntry->mDirectoryID == DirectoryID 
     210                        && delEntry->mFilename == rFilename) 
    172211                { 
    173212                        // Found! 
     
    187226                mFileNoDeleteList.push_back(std::pair<int64_t, BackupStoreFilename>(DirectoryID, rFilename)); 
    188227        } 
    189  
    190 } 
    191  
    192  
    193  
    194  
    195  
     228} 
     229 
Note: See TracChangeset for help on using the changeset viewer.