Ignore:
Timestamp:
27/08/2010 10:18:57 (21 months ago)
Author:
chris
Message:

Change the store info file format to include an account name and the
number of blocks in current (not old or deleted) files, an
often-requested feature since this number is difficult to calculate
otherwise, because files may be both old and deleted, thus counted
twice.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/backupstore/BackupStoreCheck2.cpp

    r2481 r2702  
    574574{ 
    575575        // Attempt to load the existing store info file 
    576         std::auto_ptr<BackupStoreInfo> poldInfo; 
     576        std::auto_ptr<BackupStoreInfo> pOldInfo; 
    577577        try 
    578578        { 
    579                 poldInfo.reset(BackupStoreInfo::Load(mAccountID, mStoreRoot, mDiscSetNumber, true /* read only */).release()); 
     579                pOldInfo.reset(BackupStoreInfo::Load(mAccountID, mStoreRoot, mDiscSetNumber, true /* read only */).release()); 
     580                mAccountName = pOldInfo->GetAccountName(); 
    580581        } 
    581582        catch(...) 
     
    584585                ++mNumberErrorsFound; 
    585586        } 
     587 
     588        BOX_NOTICE("Total files: " << mNumFiles << " (of which " 
     589                "old files: " << mNumOldFiles << ", " 
     590                "deleted files: " << mNumDeletedFiles << "), " 
     591                "directories: " << mNumDirectories); 
    586592 
    587593        // Minimum soft and hard limits 
     
    590596 
    591597        // Need to do anything? 
    592         if(poldInfo.get() != 0 && mNumberErrorsFound == 0 && poldInfo->GetAccountID() == mAccountID) 
     598        if(pOldInfo.get() != 0 && 
     599                mNumberErrorsFound == 0 && 
     600                pOldInfo->GetAccountID() == mAccountID) 
    593601        { 
    594602                // Leave the store info as it is, no need to alter it because nothing really changed, 
     
    602610        int64_t softLimit = minSoft; 
    603611        int64_t hardLimit = minHard; 
    604         if(poldInfo.get() != 0 && poldInfo->GetBlocksSoftLimit() > minSoft) 
    605         { 
    606                 softLimit = poldInfo->GetBlocksSoftLimit(); 
     612        if(pOldInfo.get() != 0 && pOldInfo->GetBlocksSoftLimit() > minSoft) 
     613        { 
     614                softLimit = pOldInfo->GetBlocksSoftLimit(); 
    607615        } 
    608616        else 
    609617        { 
    610                 BOX_WARNING("Soft limit for account changed to ensure housekeeping doesn't delete files on next run."); 
    611         } 
    612         if(poldInfo.get() != 0 && poldInfo->GetBlocksHardLimit() > minHard) 
    613         { 
    614                 hardLimit = poldInfo->GetBlocksHardLimit(); 
     618                BOX_WARNING("Soft limit for account changed to ensure " 
     619                        "housekeeping doesn't delete files on next run."); 
     620        } 
     621        if(pOldInfo.get() != 0 && pOldInfo->GetBlocksHardLimit() > minHard) 
     622        { 
     623                hardLimit = pOldInfo->GetBlocksHardLimit(); 
    615624        } 
    616625        else 
    617626        { 
    618                 BOX_WARNING("Hard limit for account changed to ensure housekeeping doesn't delete files on next run."); 
     627                BOX_WARNING("Hard limit for account changed to ensure " 
     628                        "housekeeping doesn't delete files on next run."); 
    619629        } 
    620630         
     
    629639        std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::CreateForRegeneration( 
    630640                mAccountID, 
     641                mAccountName, 
    631642                mStoreRoot, 
    632643                mDiscSetNumber, 
    633644                lastObjID, 
    634645                mBlocksUsed, 
     646                mBlocksInCurrentFiles, 
    635647                mBlocksInOldFiles, 
    636648                mBlocksInDeletedFiles, 
     
    638650                softLimit, 
    639651                hardLimit)); 
     652        info->AdjustNumFiles(mNumFiles); 
     653        info->AdjustNumOldFiles(mNumOldFiles); 
     654        info->AdjustNumDeletedFiles(mNumDeletedFiles); 
     655        info->AdjustNumDirectories(mNumDirectories); 
     656 
     657        if(pOldInfo.get()) 
     658        { 
     659                mNumberErrorsFound += info->ReportChangesTo(*pOldInfo); 
     660        } 
    640661 
    641662        // Save to disc? 
Note: See TracChangeset for help on using the changeset viewer.