[Box Backup-dev] COMMIT r527 - box/chris/general/bin/bbackupd
Ben Summers
boxbackup-dev@fluffy.co.uk
Sun, 26 Feb 2006 20:01:37 +0000
Writing an automated test for this feature is going to be a
_nightmare_ ...
Ben
On 26 Feb 2006, at 19:54, subversion@fluffy.co.uk wrote:
> Author: chris
> Date: 2006-02-26 19:54:24 +0000 (Sun, 26 Feb 2006)
> New Revision: 527
>
> Modified:
> box/chris/general/bin/bbackupd/BackupDaemon.cpp
> box/chris/general/bin/bbackupd/BackupDaemon.h
> Log:
> * BackupDaemon.cpp, BackupDaemon.h
> - Only mark the store object info file for deletion if we successfully
> save it at the end of a backup run.
>
>
> Modified: box/chris/general/bin/bbackupd/BackupDaemon.cpp
> ===================================================================
> --- box/chris/general/bin/bbackupd/BackupDaemon.cpp 2006-02-26
> 19:44:06 UTC (rev 526)
> +++ box/chris/general/bin/bbackupd/BackupDaemon.cpp 2006-02-26
> 19:54:24 UTC (rev 527)
> @@ -578,9 +578,8 @@
> BackupClientContext::ClientStoreMarker_NotKnown;
> // haven't contacted the store yet
>
> - bool deserialised = DeserializeStoreObjectInfo(clientStoreMarker,
> - lastSyncTime, nextSyncTime);
> - bool was_deserialised = deserialised;
> + bool deleteStoreObjectInfoFile = DeserializeStoreObjectInfo(
> + clientStoreMarker, lastSyncTime, nextSyncTime);
>
> //
> ----------------------------------------------------------------------
> ----------------------
>
> @@ -686,7 +685,8 @@
> // Delete the serialised store object file,
> // so that we don't try to reload it after a
> // partially completed backup
> - if(deserialised && !DeleteStoreObjectInfo())
> + if(deleteStoreObjectInfoFile &&
> + !DeleteStoreObjectInfo())
> {
> ::syslog(LOG_ERR, "Failed to delete the "
> "StoreObjectInfoFile, backup cannot "
> @@ -697,8 +697,7 @@
> // In case the backup throws an exception,
> // we should not try to delete the store info
> // object file again.
> - was_deserialised = deserialised;
> - deserialised = false;
> + deleteStoreObjectInfoFile = false;
>
> // Do sync
> bool errorOccurred = false;
> @@ -807,12 +806,15 @@
>
> //
> ----------------------------------------------------------------------
> ----------------------
>
> - // We had a successful backup, save the store info
> - SerializeStoreObjectInfo(clientStoreMarker, lastSyncTime,
> nextSyncTime);
> - // Next time around, make sure we delete
> - // the store info object file.
> - deserialised = was_deserialised;
> + // We had a successful backup, save the store
> + // info. If we save successfully, we must
> + // delete the file next time we start a backup
>
> + deleteStoreObjectInfoFile =
> + SerializeStoreObjectInfo(
> + clientStoreMarker,
> + lastSyncTime, nextSyncTime);
> +
> //
> ----------------------------------------------------------------------
> ----------------------
> }
> catch(BoxException &e)
> @@ -2250,11 +2252,11 @@
> static const std::string STOREOBJECTINFO_MAGIC_ID_STRING =
> "BBACKUPD-STATE";
> static const int STOREOBJECTINFO_VERSION = 1;
>
> -void BackupDaemon::SerializeStoreObjectInfo(int64_t
> aClientStoreMarker, box_time_t theLastSyncTime, box_time_t
> theNextSyncTime) const
> +bool BackupDaemon::SerializeStoreObjectInfo(int64_t
> aClientStoreMarker, box_time_t theLastSyncTime, box_time_t
> theNextSyncTime) const
> {
> if(!GetConfiguration().KeyExists("StoreObjectInfoFile"))
> {
> - return;
> + return false;
> }
>
> std::string StoreObjectInfoFile =
> @@ -2262,13 +2264,17 @@
>
> if (StoreObjectInfoFile.size() <= 0)
> {
> - return;
> + return false;
> }
>
> + bool created = false;
> +
> try
> {
> FileStream aFile(StoreObjectInfoFile.c_str(),
> O_WRONLY | O_CREAT | O_TRUNC);
> + created = true;
> +
> Archive anArchive(aFile, 0);
>
> anArchive.Write(STOREOBJECTINFO_MAGIC_ID_VALUE);
> @@ -2313,6 +2319,8 @@
> "not accessible or could not be created",
> StoreObjectInfoFile.c_str());
> }
> +
> + return created;
> }
>
> //
> ----------------------------------------------------------------------
> ----
>
> Modified: box/chris/general/bin/bbackupd/BackupDaemon.h
> ===================================================================
> --- box/chris/general/bin/bbackupd/BackupDaemon.h 2006-02-26
> 19:44:06 UTC (rev 526)
> +++ box/chris/general/bin/bbackupd/BackupDaemon.h 2006-02-26
> 19:54:24 UTC (rev 527)
> @@ -46,9 +46,12 @@
> ~BackupDaemon();
>
> private:
> - // methods below do partial (specialized) serialization of client
> state only
> - void SerializeStoreObjectInfo(int64_t aClientStoreMarker,
> box_time_t theLastSyncTime, box_time_t theNextSyncTime) const;
> - bool DeserializeStoreObjectInfo(int64_t & aClientStoreMarker,
> box_time_t & theLastSyncTime, box_time_t & theNextSyncTime);
> + // methods below do partial (specialized) serialization of
> + // client state only
> + bool SerializeStoreObjectInfo(int64_t aClientStoreMarker,
> + box_time_t theLastSyncTime, box_time_t theNextSyncTime) const;
> + bool DeserializeStoreObjectInfo(int64_t & aClientStoreMarker,
> + box_time_t & theLastSyncTime, box_time_t & theNextSyncTime);
> bool DeleteStoreObjectInfo() const;
> BackupDaemon(const BackupDaemon &);
> public:
>
> _______________________________________________
> Boxbackup-dev mailing list
> Boxbackup-dev@fluffy.co.uk
> http://lists.warhead.org.uk/mailman/listinfo/boxbackup-dev