Changeset 3025


Ignore:
Timestamp:
12/10/2011 00:41:47 (8 months ago)
Author:
chris
Message:

Convert VSS path to original path for log messages in UpdateItems?, to
help admins to interpret them.

File:
1 edited

Legend:

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

    r3023 r3025  
    773773                // Filename of this file 
    774774                std::string filename(MakeFullPath(rLocalPath, *f)); 
     775                std::string nonVssFilePath = ConvertVssPathToRealPath(filename, 
     776                        rBackupLocation); 
    775777 
    776778                // Get relevant info about file 
     
    786788                        if(EMU_LSTAT(filename.c_str(), &st) != 0) 
    787789                        { 
    788                                 rNotifier.NotifyFileStatFailed(this,  
    789                                         filename, strerror(errno)); 
     790                                rNotifier.NotifyFileStatFailed(this, nonVssFilePath, 
     791                                        strerror(errno)); 
    790792 
    791793                                // Report the error (logs and  
    792794                                // eventual email to administrator) 
    793                                 SetErrorWhenReadingFilesystemObject(rParams, filename); 
     795                                SetErrorWhenReadingFilesystemObject(rParams, nonVssFilePath); 
    794796 
    795797                                // Ignore this entry for now. 
     
    846848                                box_time_t srvModTime = 0, srvAttributesHash = 0; 
    847849                                BackupStoreFilenameClear oldLeafname; 
    848                                 if(rContext.FindFilename(renameObjectID, renameInDirectory, localPotentialOldName, isDir, isCurrentVersion, &srvModTime, &srvAttributesHash, &oldLeafname)) 
     850                                if(rContext.FindFilename(renameObjectID, renameInDirectory, 
     851                                        localPotentialOldName, isDir, isCurrentVersion, 
     852                                        &srvModTime, &srvAttributesHash, &oldLeafname)) 
    849853                                {        
    850854                                        // Only interested if it's a file and the latest version 
     
    866870                                                        { 
    867871                                                                // Rename the existing files (ie include old versions) on the server 
    868                                                                 connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */, 
     872                                                                connection.QueryMoveObject(renameObjectID, 
     873                                                                        renameInDirectory, 
     874                                                                        mObjectID /* move to this directory */, 
    869875                                                                        BackupProtocolMoveObject::Flags_MoveAllWithSameName |  
    870876                                                                        BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject, 
     
    877883                                                                // Create new entry in the directory for it 
    878884                                                                // -- will be near enough what's actually on the server for the rest to work. 
    879                                                                 en = pDirOnStore->AddEntry(storeFilename, srvModTime, renameObjectID, 0 /* size in blocks unknown, but not needed */, 
    880                                                                         BackupStoreDirectory::Entry::Flags_File, srvAttributesHash); 
     885                                                                en = pDirOnStore->AddEntry(storeFilename, 
     886                                                                        srvModTime, renameObjectID, 
     887                                                                        0 /* size in blocks unknown, but not needed */, 
     888                                                                        BackupStoreDirectory::Entry::Flags_File, 
     889                                                                        srvAttributesHash); 
    881890                                                         
    882891                                                                // Store the object ID for the inode lookup map later 
     
    920929 
    921930                bool doUpload = false; 
     931                std::string decisionReason = "unknown"; 
    922932 
    923933                // Only upload a file if the mod time locally is  
     
    935945                                { 
    936946                                        doUpload = true; 
    937                                         BOX_TRACE("Upload decision: " << 
    938                                                 filename << ": will upload " 
    939                                                 "(not on server)"); 
     947                                        decisionReason = "not on server"; 
    940948                                } 
    941949                                else if (modTime >= rParams.mSyncPeriodStart) 
    942950                                { 
    943951                                        doUpload = true; 
    944                                         BOX_TRACE("Upload decision: " << 
    945                                                 filename << ": will upload " 
    946                                                 "(modified since last sync)"); 
     952                                        decisionReason = "modified since last sync"; 
    947953                                } 
    948954                        } 
     
    961967                        { 
    962968                                doUpload = true; 
    963                                 BOX_TRACE("Upload decision: " << 
    964                                         filename << ": will upload " 
    965                                         "(continually modified)"); 
     969                                decisionReason = "continually modified"; 
    966970                        } 
    967971 
     
    979983                        { 
    980984                                doUpload = true; 
    981                                 BOX_TRACE("Upload decision: " << 
    982                                         filename << ": will upload " 
    983                                         "(mod time changed)"); 
     985                                decisionReason = "mod time changed"; 
    984986                        } 
    985987 
     
    992994                        { 
    993995                                doUpload = true; 
    994                                 BOX_TRACE("Upload decision: " << 
    995                                         filename << ": will upload " 
    996                                         "(mod time in the future)"); 
     996                                decisionReason = "mod time in the future"; 
    997997                        } 
    998998                } 
     
    10001000                if (en != 0 && en->GetModificationTime() == modTime) 
    10011001                { 
    1002                         BOX_TRACE("Upload decision: " << 
    1003                                 filename << ": will not upload " 
    1004                                 "(not modified since last upload)"); 
     1002                        doUpload = false; 
     1003                        decisionReason = "not modified since last upload"; 
    10051004                } 
    10061005                else if (!doUpload) 
     
    10111010                                int age = BoxTimeToSeconds(now - 
    10121011                                        modTime); 
    1013                                 BOX_TRACE("Upload decision: " << 
    1014                                         filename << ": will not upload " 
    1015                                         "(modified too recently: " 
    1016                                         "only " << age << " seconds ago)"); 
     1012                                std::ostringstream s; 
     1013                                s << "modified too recently: " 
     1014                                        "only " << age << " seconds ago"; 
     1015                                decisionReason = s.str(); 
    10171016                        } 
    10181017                        else 
    10191018                        { 
    1020                                 BOX_TRACE("Upload decision: " << 
    1021                                         filename << ": will not upload " 
    1022                                         "(mod time is " << modTime <<  
     1019                                std::ostringstream s; 
     1020                                s << "mod time is " << modTime <<  
    10231021                                        " which is outside sync window, " 
    10241022                                        << rParams.mSyncPeriodStart << " to " 
    1025                                         << rParams.mSyncPeriodEnd << ")"); 
    1026                         } 
    1027                 } 
     1023                                        << rParams.mSyncPeriodEnd; 
     1024                                decisionReason = s.str(); 
     1025                        } 
     1026                } 
     1027 
     1028                BOX_TRACE("Upload decision: " << nonVssFilePath << ": " << 
     1029                        (doUpload ? "will upload" : "will not upload") << 
     1030                        "(" << decisionReason << ")"); 
    10281031 
    10291032                bool fileSynced = true; 
     
    10791082                                        // more problems. 
    10801083                                        rNotifier.NotifyFileUploadException( 
    1081                                                 this, filename, e); 
     1084                                                this, nonVssFilePath, e); 
    10821085                                        throw; 
    10831086                                } 
     
    10961099                                        allUpdatedSuccessfully = false; 
    10971100                                        // Log it. 
    1098                                         SetErrorWhenReadingFilesystemObject(rParams, filename); 
    1099                                         rNotifier.NotifyFileUploadException(this, filename, e); 
     1101                                        SetErrorWhenReadingFilesystemObject(rParams, 
     1102                                                nonVssFilePath); 
     1103                                        rNotifier.NotifyFileUploadException(this, 
     1104                                                nonVssFilePath, e); 
    11001105                                } 
    11011106 
     
    11151120                        else 
    11161121                        { 
    1117                                 rNotifier.NotifyFileSkippedServerFull(this, 
    1118                                         ConvertVssPathToRealPath(filename, rBackupLocation)); 
     1122                                rNotifier.NotifyFileSkippedServerFull(this, nonVssFilePath); 
    11191123                        } 
    11201124                } 
     
    11361140                                try 
    11371141                                { 
    1138                                         rNotifier.NotifyFileUploadingAttributes( 
    1139                                                 this, filename); 
     1142                                        rNotifier.NotifyFileUploadingAttributes(this, 
     1143                                                nonVssFilePath); 
    11401144                                         
    11411145                                        // Update store 
     
    11481152                                catch (BoxException &e) 
    11491153                                { 
    1150                                         BOX_ERROR("Failed to read or store " 
    1151                                                 "file attributes for '" << 
    1152                                                 filename << "', will try " 
    1153                                                 "again later"); 
     1154                                        BOX_ERROR("Failed to read or store file attributes "  
     1155                                                "for '" << nonVssFilePath << "', will try again " 
     1156                                                "later"); 
    11541157                                } 
    11551158                        } 
     
    11951198                                // Use this one 
    11961199                                BOX_TRACE("Storing uploaded file ID " << 
    1197                                         inodeNum << " (" << filename << ") " 
     1200                                        inodeNum << " (" << nonVssFilePath << ") " 
    11981201                                        "in ID map as object " << 
    11991202                                        latestObjectID << " with parent " << 
     
    12121215                                        if (dirid != mObjectID) 
    12131216                                        { 
    1214                                                 BOX_WARNING("Found conflicting parent ID for file ID " << inodeNum << " (" << filename << "): expected " << mObjectID << " but found " << dirid << " (same directory used in two different locations?)"); 
     1217                                                BOX_WARNING("Found conflicting parent ID for " 
     1218                                                        "file ID " << inodeNum << " (" << 
     1219                                                        nonVssFilePath << "): expected " << 
     1220                                                        mObjectID << " but found " << dirid << 
     1221                                                        " (same directory used in two different " 
     1222                                                        "locations?)"); 
    12151223                                        } 
    12161224 
     
    12221230                                        // not indicate anything wrong. 
    12231231                                        // Run the release version for real life use, where this check is not made. 
    1224                                         BOX_TRACE("Storing found file ID " << 
    1225                                                 inodeNum << " (" << filename << 
    1226                                                 ") in ID map as object " << 
    1227                                                 objid << " with parent " << 
    1228                                                 mObjectID); 
     1232                                        BOX_TRACE("Storing found file ID " << inodeNum << 
     1233                                                " (" << nonVssFilePath << ") in ID map as " 
     1234                                                "object " << objid << " with parent " << mObjectID); 
    12291235                                        idMap.AddToMap(inodeNum, objid, 
    12301236                                                mObjectID /* containing directory */); 
     
    12351241                if (fileSynced) 
    12361242                { 
    1237                         rNotifier.NotifyFileSynchronised(this, filename, 
     1243                        rNotifier.NotifyFileSynchronised(this, nonVssFilePath, 
    12381244                                fileSize); 
    12391245                } 
     
    12611267                // Get the local filename 
    12621268                std::string dirname(MakeFullPath(rLocalPath, *d)); 
     1269                std::string nonVssDirPath = ConvertVssPathToRealPath(dirname, 
     1270                        rBackupLocation); 
    12631271         
    12641272                // See if it's in the listing (if we have one) 
     
    13521360                                                "of directory, cannot check " 
    13531361                                                "for rename, assuming new: '" 
    1354                                                 << dirname << "'"); 
     1362                                                << nonVssDirPath << "'"); 
    13551363                                        failedToReadAttributes = true; 
    13561364                                } 
     
    13701378                                        bool isDir = false; 
    13711379                                        bool isCurrentVersion = false; 
    1372                                         if(rContext.FindFilename(renameObjectID, renameInDirectory, localPotentialOldName, isDir, isCurrentVersion)) 
     1380                                        if(rContext.FindFilename(renameObjectID, 
     1381                                                renameInDirectory, localPotentialOldName, 
     1382                                                isDir, isCurrentVersion)) 
    13731383                                        {        
    13741384                                                // Only interested if it's a directory 
     
    14001410                                { 
    14011411                                        // Rename the existing directory on the server 
    1402                                         connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */, 
     1412                                        connection.QueryMoveObject(renameObjectID, 
     1413                                                renameInDirectory, 
     1414                                                mObjectID /* move to this directory */, 
    14031415                                                BackupProtocolMoveObject::Flags_MoveAllWithSameName |  
    14041416                                                BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject, 
     
    14191431                                { 
    14201432                                        // Create a new directory 
    1421                                         std::auto_ptr<BackupProtocolSuccess> dirCreate(connection.QueryCreateDirectory( 
    1422                                                 mObjectID, attrModTime, storeFilename, attrStream)); 
     1433                                        std::auto_ptr<BackupProtocolSuccess> dirCreate( 
     1434                                                connection.QueryCreateDirectory( 
     1435                                                        mObjectID, attrModTime, storeFilename,  
     1436                                                        attrStream)); 
    14231437                                        subDirObjectID = dirCreate->GetObjectID();  
    14241438                                         
     
    14271441                                        rNotifier.NotifyDirectoryCreated(subDirObjectID, 
    14281442                                                storeFilename.GetClearFilename(), 
    1429                                                 dirname); 
     1443                                                nonVssDirPath); 
    14301444                                } 
    14311445                        } 
     
    14911505                        std::string localName = MakeFullPath(rLocalPath, 
    14921506                                clear.GetClearFilename()); 
     1507                        std::string nonVssLocalName = ConvertVssPathToRealPath(localName, 
     1508                                rBackupLocation); 
    14931509                         
    14941510                        // Delete this entry -- file or directory? 
     
    15161532                                        delete rec; 
    15171533 
    1518                                         std::string name = MakeFullPath( 
    1519                                                 rLocalPath,  
    1520                                                 dirname.GetClearFilename()); 
    1521  
    1522                                         BOX_TRACE("Deleted directory record " 
    1523                                                 "for " << name); 
     1534                                        BOX_TRACE("Deleted directory record for " <<  
     1535                                                nonVssLocalName); 
    15241536                                }                                
    15251537                        } 
Note: See TracChangeset for help on using the changeset viewer.