Changeset 2401

Show
Ignore:
Timestamp:
05/12/2008 20:56:00 (15 months ago)
Author:
chris
Message:

Catch exceptions from BackupClientFileAttributes::ReadAttributes?
during backup, and report which file caused them.

If we cannot read the attributes of a directory to find its inode
number, assume that it hasn't been renamed.

Reformat "Storing uploaded file ID" log line to shorten source code
lines.

Change "Storing uploaded file ID" and "Found conflicting parent ID"
messages not to print the path, which duplicates data earlier in the
same message.

Fix typo in comment.

Files:
1 modified

Legend:

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

    r2394 r2401  
    10401040                        if(!rContext.StorageLimitExceeded()) 
    10411041                        { 
    1042                                 // Update store 
    1043                                 BackupClientFileAttributes attr; 
    1044                                 attr.ReadAttributes(filename.c_str(), false /* put mod times in the attributes, please */); 
    1045                                 MemBlockStream attrStream(attr); 
    1046                                 connection.QuerySetReplacementFileAttributes(mObjectID, attributesHash, storeFilename, attrStream); 
    1047                                 fileSynced = true; 
     1042                                try 
     1043                                { 
     1044                                        // Update store 
     1045                                        BackupClientFileAttributes attr; 
     1046                                        attr.ReadAttributes(filename.c_str(), false /* put mod times in the attributes, please */); 
     1047                                        MemBlockStream attrStream(attr); 
     1048                                        connection.QuerySetReplacementFileAttributes(mObjectID, attributesHash, storeFilename, attrStream); 
     1049                                        fileSynced = true; 
     1050                                } 
     1051                                catch (BoxException &e) 
     1052                                { 
     1053                                        BOX_ERROR("Failed to read or store " 
     1054                                                "file attributes for '" << 
     1055                                                filename << "', will try " 
     1056                                                "again later"); 
     1057                                } 
    10481058                        } 
    10491059                } 
     
    10871097                        { 
    10881098                                // Use this one 
    1089                                 BOX_TRACE("Storing uploaded file ID " << inodeNum << " (" << filename << ") in ID map as object " << latestObjectID << " with parent " << mObjectID << " (" << rLocalPath << ")"); 
     1099                                BOX_TRACE("Storing uploaded file ID " << 
     1100                                        inodeNum << " (" << filename << ") " 
     1101                                        "in ID map as object " << 
     1102                                        latestObjectID << " with parent " << 
     1103                                        mObjectID); 
    10901104                                idMap.AddToMap(inodeNum, latestObjectID, mObjectID /* containing directory */); 
    10911105                        } 
     
    11011115                                        if (dirid != mObjectID) 
    11021116                                        { 
    1103                                                 BOX_WARNING("Found conflicting parent ID for file ID " << inodeNum << " (" << filename << "): expected " << mObjectID << " (" << rLocalPath << ") but found " << dirid << " (same directory used in two different locations?)"); 
     1117                                                BOX_WARNING("Found conflicting parent ID for file ID " << inodeNum << " (" << filename << "): expected " << mObjectID << " but found " << dirid << " (same directory used in two different locations?)"); 
    11041118                                        } 
    11051119 
     
    11111125                                        // not indicate anything wrong. 
    11121126                                        // Run the release version for real life use, where this check is not made. 
    1113                                         BOX_TRACE("Storing found file ID " << inodeNum << " (" << filename << ") in ID map as object " << latestObjectID << " with parent " << mObjectID << " (" << rLocalPath << ")"); 
    1114                                         idMap.AddToMap(inodeNum, objid, mObjectID /* containing directory */);                           
     1127                                        BOX_TRACE("Storing found file ID " << 
     1128                                                inodeNum << " (" << filename << 
     1129                                                ") in ID map as object " << 
     1130                                                objid << " with parent " << 
     1131                                                mObjectID); 
     1132                                        idMap.AddToMap(inodeNum, objid, 
     1133                                                mObjectID /* containing directory */); 
    11151134                                } 
    11161135                        } 
     
    11731192 
    11741193                // Flag for having created directory, so can optimise the 
    1175                 // recusive call not to read it again, because we know 
     1194                // recursive call not to read it again, because we know 
    11761195                // it's empty. 
    11771196                bool haveJustCreatedDirOnServer = false; 
     
    11791198                // Next, see if it's in the list of sub directories 
    11801199                BackupClientDirectoryRecord *psubDirRecord = 0; 
    1181                 std::map<std::string, BackupClientDirectoryRecord *>::iterator e(mSubDirectories.find(*d)); 
     1200                std::map<std::string, BackupClientDirectoryRecord *>::iterator 
     1201                        e(mSubDirectories.find(*d)); 
     1202 
    11821203                if(e != mSubDirectories.end()) 
    11831204                { 
     
    12191240                                InodeRefType inodeNum = 0; 
    12201241                                BackupClientFileAttributes attr; 
    1221                                 attr.ReadAttributes(dirname.c_str(), true /* directories have zero mod times */, 
    1222                                         0 /* not interested in mod time */, &attrModTime, 0 /* not file size */, 
    1223                                         &inodeNum); 
     1242                                bool failedToReadAttributes = false; 
     1243 
     1244                                try 
     1245                                { 
     1246                                        attr.ReadAttributes(dirname.c_str(), 
     1247                                                true /* directories have zero mod times */, 
     1248                                                0 /* not interested in mod time */, 
     1249                                                &attrModTime, 0 /* not file size */, 
     1250                                                &inodeNum); 
     1251                                } 
     1252                                catch (BoxException &e) 
     1253                                { 
     1254                                        BOX_WARNING("Failed to read attributes " 
     1255                                                "of directory, cannot check " 
     1256                                                "for rename, assuming new: '" 
     1257                                                << dirname << "'"); 
     1258                                        failedToReadAttributes = true; 
     1259                                } 
    12241260 
    12251261                                // Check to see if the directory been renamed 
     
    12291265                                const BackupClientInodeToIDMap &idMap( 
    12301266                                        rContext.GetCurrentIDMap()); 
    1231                                 if(idMap.Lookup(inodeNum, renameObjectID, renameInDirectory)) 
     1267 
     1268                                if(!failedToReadAttributes && idMap.Lookup(inodeNum, 
     1269                                        renameObjectID, renameInDirectory)) 
    12321270                                { 
    12331271                                        // Look up on the server to get the name, to build the local filename