[Box Backup-commit] COMMIT r3273 - box/trunk/lib/backupstore
subversion at boxbackup.org
subversion at boxbackup.org
Thu Feb 13 23:29:27 GMT 2014
Author: chris
Date: 2014-02-13 23:29:27 +0000 (Thu, 13 Feb 2014)
New Revision: 3273
Modified:
box/trunk/lib/backupstore/BackupStoreFile.cpp
box/trunk/lib/backupstore/BackupStoreFile.h
Log:
Add a shortcut interface to uploading a new file.
Useful in tests.
Modified: box/trunk/lib/backupstore/BackupStoreFile.cpp
===================================================================
--- box/trunk/lib/backupstore/BackupStoreFile.cpp 2014-02-13 23:19:28 UTC (rev 3272)
+++ box/trunk/lib/backupstore/BackupStoreFile.cpp 2014-02-13 23:29:27 UTC (rev 3273)
@@ -1556,3 +1556,42 @@
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();
+}
+
Modified: box/trunk/lib/backupstore/BackupStoreFile.h
===================================================================
--- box/trunk/lib/backupstore/BackupStoreFile.h 2014-02-13 23:19:28 UTC (rev 3272)
+++ box/trunk/lib/backupstore/BackupStoreFile.h 2014-02-13 23:29:27 UTC (rev 3273)
@@ -14,6 +14,7 @@
#include <memory>
#include <cstdlib>
+#include "autogen_BackupProtocol.h"
#include "BackupClientFileAttributes.h"
#include "BackupStoreFilename.h"
#include "IOStream.h"
@@ -40,6 +41,8 @@
// Have some memory allocation commands, note closing "Off" at end of file.
#include "MemLeakFindOn.h"
+class BackupStoreFileEncodeStream;
+
// --------------------------------------------------------------------------
//
// Class
@@ -60,8 +63,6 @@
virtual bool IsManaged() = 0;
};
-class BackupStoreFileEncodeStream;
-
// --------------------------------------------------------------------------
//
// Class
@@ -139,6 +140,16 @@
int64_t *pModificationTime = 0,
bool *pIsCompletelyDifferent = 0
);
+ // Shortcut interface
+ static int64_t QueryStoreFileDiff(BackupProtocolCallable& protocol,
+ const std::string& LocalFilename, int64_t DirectoryObjectID,
+ int64_t DiffFromFileID, int64_t AttributesHash,
+ const BackupStoreFilenameClear& StoreFilename,
+ int Timeout = IOStream::TimeOutInfinite,
+ DiffTimer *pDiffTimer = NULL,
+ ReadLoggingStream::Logger* pLogger = NULL,
+ RunStatusProvider* pRunStatusProvider = NULL);
+
static bool VerifyEncodedFileFormat(IOStream &rFile, int64_t *pDiffFromObjectIDOut = 0, int64_t *pContainerIDOut = 0);
static void CombineFile(IOStream &rDiff, IOStream &rDiff2, IOStream &rFrom, IOStream &rOut);
static void CombineDiffs(IOStream &rDiff1, IOStream &rDiff2, IOStream &rDiff2b, IOStream &rOut);
More information about the Boxbackup-commit
mailing list