Changeset 2144
- Timestamp:
- 09/04/2008 22:04:14 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/backupclient/BackupClientRestore.cpp
r2127 r2144 203 203 // 204 204 // Function 205 // Name: BackupClientRestoreDir(BackupProtocolClient &, int64_t, const char *, bool) 205 // Name: BackupClientRestoreDir(BackupProtocolClient &, 206 // int64_t, const char *, bool) 206 207 // Purpose: Restore a directory 207 208 // Created: 23/11/03 208 209 // 209 210 // -------------------------------------------------------------------------- 210 static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t DirectoryID, std::string &rLocalDirectoryName, 211 static int BackupClientRestoreDir(BackupProtocolClient &rConnection, 212 int64_t DirectoryID, std::string &rLocalDirectoryName, 211 213 RestoreParams &Params, RestoreResumeInfo &rLevel) 212 214 { 213 // If we're resuming... check that we haven't got a next level to look at 215 // If we're resuming... check that we haven't got a next level to 216 // look at 214 217 if(rLevel.mpNextLevel != 0) 215 218 { 216 219 // Recurse immediately 217 std::string localDirname(rLocalDirectoryName + DIRECTORY_SEPARATOR_ASCHAR + rLevel.mNextLevelLocalName); 218 BackupClientRestoreDir(rConnection, rLevel.mNextLevelID, localDirname, Params, *rLevel.mpNextLevel); 220 std::string localDirname(rLocalDirectoryName + 221 DIRECTORY_SEPARATOR_ASCHAR + 222 rLevel.mNextLevelLocalName); 223 BackupClientRestoreDir(rConnection, rLevel.mNextLevelID, 224 localDirname, Params, *rLevel.mpNextLevel); 219 225 220 226 // Add it to the list of done itmes … … 260 266 case ObjectExists_File: 261 267 { 262 // File exists with this name, which is fun. Get rid of it. 268 // File exists with this name, which is fun. 269 // Get rid of it. 263 270 BOX_WARNING("File present with name '" << 264 rLocalDirectoryName << "', removing " <<271 rLocalDirectoryName << "', removing " 265 272 "out of the way of restored directory. " 266 273 "Use specific restore with ID to " … … 407 414 // list of files which is appropriate to the restore type 408 415 rConnection.QueryListDirectory( 409 DirectoryID,410 Params.RestoreDeleted?(BackupProtocolClientListDirectory::Flags_Deleted):(BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING),411 BackupProtocolClientListDirectory::Flags_OldVersion | (Params.RestoreDeleted?(0):(BackupProtocolClientListDirectory::Flags_Deleted)),412 true /* want attributes */);416 DirectoryID, 417 Params.RestoreDeleted?(BackupProtocolClientListDirectory::Flags_Deleted):(BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING), 418 BackupProtocolClientListDirectory::Flags_OldVersion | (Params.RestoreDeleted?(0):(BackupProtocolClientListDirectory::Flags_Deleted)), 419 true /* want attributes */); 413 420 414 421 // Retrieve the directory from the stream following … … 444 451 BackupStoreDirectory::Iterator i(dir); 445 452 BackupStoreDirectory::Entry *en = 0; 446 while((en = i.Next(BackupStoreDirectory::Entry::Flags_File)) != 0) 453 while((en = i.Next(BackupStoreDirectory::Entry::Flags_File)) 454 != 0) 447 455 { 448 456 // Check ID hasn't already been done 449 if(rLevel.mRestoredObjects.find(en->GetObjectID()) == rLevel.mRestoredObjects.end()) 457 if(rLevel.mRestoredObjects.find(en->GetObjectID()) 458 == rLevel.mRestoredObjects.end()) 450 459 { 451 460 // Local name … … 458 467 // For resuming restores, we can't overwrite 459 468 // files already there. 460 if(ObjectExists(localFilename) != ObjectExists_NoObject && 469 if(ObjectExists(localFilename) 470 != ObjectExists_NoObject && 461 471 ::unlink(localFilename.c_str()) != 0) 462 472 { … … 550 560 { 551 561 // File exists... 552 bytesWrittenSinceLastRestoreInfoSave += fileSize; 562 bytesWrittenSinceLastRestoreInfoSave 563 += fileSize; 553 564 554 565 if(bytesWrittenSinceLastRestoreInfoSave > MAX_BYTES_WRITTEN_BETWEEN_RESTORE_INFO_SAVES) 555 566 { 556 // Save the restore info, in case it's needed later 567 // Save the restore info, in 568 // case it's needed later 557 569 try 558 570 { … … 613 625 BackupStoreDirectory::Iterator i(dir); 614 626 BackupStoreDirectory::Entry *en = 0; 615 while((en = i.Next(BackupStoreDirectory::Entry::Flags_Dir)) != 0) 627 while((en = i.Next(BackupStoreDirectory::Entry::Flags_Dir)) 628 != 0) 616 629 { 617 630 // Check ID hasn't already been done 618 if(rLevel.mRestoredObjects.find(en->GetObjectID()) == rLevel.mRestoredObjects.end()) 631 if(rLevel.mRestoredObjects.find(en->GetObjectID()) 632 == rLevel.mRestoredObjects.end()) 619 633 { 620 634 // Local name 621 635 BackupStoreFilenameClear nm(en->GetName()); 622 std::string localDirname(rLocalDirectoryName + DIRECTORY_SEPARATOR_ASCHAR + nm.GetClearFilename()); 636 std::string localDirname(rLocalDirectoryName 637 + DIRECTORY_SEPARATOR_ASCHAR 638 + nm.GetClearFilename()); 623 639 624 640 // Add the level for the next entry 625 RestoreResumeInfo &rnextLevel(rLevel.AddLevel(en->GetObjectID(), nm.GetClearFilename())); 641 RestoreResumeInfo &rnextLevel( 642 rLevel.AddLevel(en->GetObjectID(), 643 nm.GetClearFilename())); 626 644 627 645 // Recurse … … 669 687 // 670 688 // Function 671 // Name: BackupClientRestore(BackupProtocolClient &, int64_t, const char *, bool, bool) 672 // Purpose: Restore a directory on the server to a local directory on the disc. 673 // 674 // The local directory must not already exist. 675 // 676 // If a restore is aborted for any reason, then it may be resumed if 677 // Resume == true. If Resume == false and resumption is possible, then 678 // Restore_ResumePossible is returned. 679 // 680 // Set RestoreDeleted to restore a deleted directory. This may not give the 681 // directory structure when it was deleted, because files may have been deleted 682 // within it before it was deleted. 683 // 684 // Returns Restore_TargetExists if the target directory exists, but 685 // there is no restore possible. (Won't attempt to overwrite things.) 686 // 687 // Returns Restore_Complete on success. (Exceptions on error.) 689 // Name: BackupClientRestore(BackupProtocolClient &, int64_t, 690 // const char *, bool, bool) 691 // Purpose: Restore a directory on the server to a local 692 // directory on the disc. The local directory must not 693 // already exist. 694 // 695 // If a restore is aborted for any reason, then it may 696 // be resumed if Resume == true. If Resume == false 697 // and resumption is possible, then 698 // Restore_ResumePossible is returned. 699 // 700 // Set RestoreDeleted to restore a deleted directory. 701 // This may not give the directory structure when it 702 // was deleted, because files may have been deleted 703 // within it before it was deleted. 704 // 705 // Returns Restore_TargetExists if the target 706 // directory exists, but there is no restore possible. 707 // (Won't attempt to overwrite things.) 708 // 709 // Returns Restore_Complete on success. (Exceptions 710 // on error.) 688 711 // Created: 23/11/03 689 712 // 690 713 // -------------------------------------------------------------------------- 691 int BackupClientRestore(BackupProtocolClient &rConnection, int64_t DirectoryID, const char *LocalDirectoryName, 692 bool PrintDots, bool RestoreDeleted, bool UndeleteAfterRestoreDeleted, bool Resume) 714 int BackupClientRestore(BackupProtocolClient &rConnection, 715 int64_t DirectoryID, const char *LocalDirectoryName, 716 bool PrintDots, bool RestoreDeleted, 717 bool UndeleteAfterRestoreDeleted, bool Resume) 693 718 { 694 719 // Parameter block … … 704 729 // Does any resumption information exist? 705 730 bool doingResume = false; 706 if(FileExists(params.mRestoreResumeInfoFilename.c_str()) && targetExistance == ObjectExists_Dir) 731 if(FileExists(params.mRestoreResumeInfoFilename.c_str()) && 732 targetExistance == ObjectExists_Dir) 707 733 { 708 734 if(!Resume) 709 735 { 710 // Caller didn't specify that resume should be done, so refuse to do it711 // but say why.736 // Caller didn't specify that resume should be done, 737 // so refuse to do it but say why. 712 738 return Restore_ResumePossible; 713 739 } … … 760 786 } 761 787 762 763 764
Note: See TracChangeset
for help on using the changeset viewer.
