diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-02-13 23:29:27 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-02-13 23:29:27 +0000 |
commit | ba952ab7cd6fddd1a7754544e4322ceb707e2244 (patch) | |
tree | 6dcbededdcc49197626391b9b09ae72ff86f7e7e /lib/backupstore/BackupStoreFile.cpp | |
parent | 7350aca3277d84d4818ecb34fb38bc24f9f72710 (diff) |
Add a shortcut interface to uploading a new file.
Useful in tests.
Diffstat (limited to 'lib/backupstore/BackupStoreFile.cpp')
-rw-r--r-- | lib/backupstore/BackupStoreFile.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/backupstore/BackupStoreFile.cpp b/lib/backupstore/BackupStoreFile.cpp index 519305ff..e011f8f4 100644 --- a/lib/backupstore/BackupStoreFile.cpp +++ b/lib/backupstore/BackupStoreFile.cpp @@ -1556,3 +1556,42 @@ DiffTimer::DiffTimer() DiffTimer::~DiffTimer() { } + +// Shortcut interface +int64_t BackupStoreFile::QueryStoreFileDiff(BackupProtocolCallable& protocol, + const std::string& LocalFilename, int64_t DirectoryObjectID, + int64_t DiffFromFileID, int64_t AttributesHash, + const BackupStoreFilenameClear& StoreFilename, int Timeout, + DiffTimer *pDiffTimer, ReadLoggingStream::Logger* pLogger, + RunStatusProvider* pRunStatusProvider) +{ + int64_t ModificationTime; + std::auto_ptr<BackupStoreFileEncodeStream> pStream; + + if(DiffFromFileID) + { + // Fetch the block index for this one + std::auto_ptr<BackupProtocolSuccess> getblockindex = + protocol.QueryGetBlockIndexByName(DirectoryObjectID, + StoreFilename); + ASSERT(getblockindex->GetObjectID() == DiffFromFileID); + std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream()); + + pStream = EncodeFileDiff(LocalFilename, + DirectoryObjectID, StoreFilename, DiffFromFileID, + *(blockIndexStream.get()), Timeout, pDiffTimer, + &ModificationTime, NULL // pIsCompletelyDifferent + ); + } + else + { + pStream = BackupStoreFile::EncodeFile(LocalFilename, + DirectoryObjectID, StoreFilename); + } + + std::auto_ptr<IOStream> upload(pStream.release()); + return protocol.QueryStoreFile(DirectoryObjectID, + ModificationTime, AttributesHash, DiffFromFileID, + StoreFilename, upload)->GetObjectID(); +} + |