Skip to content

Commit

Permalink
BackupDaemon: simplify DeserializeStoreObjectInfo
Browse files Browse the repository at this point in the history
Reuse the existing ResetCachedState method, to reduce code duplication.
  • Loading branch information
qris committed Dec 10, 2018
1 parent 649b339 commit ad6c791
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
21 changes: 7 additions & 14 deletions lib/bbackupd/BackupDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,7 @@ void BackupDaemon::Run2()

// --------------------------------------------------------------------------------------------

mDeleteStoreObjectInfoFile = DeserializeStoreObjectInfo(mLastSyncTime,
mNextSyncTime);
mDeleteStoreObjectInfoFile = DeserializeStoreObjectInfo();

// --------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -896,6 +895,7 @@ void BackupDaemon::ResetCachedState()
// Clear state data
// Go back to beginning of time
mLastSyncTime = 0;
mNextSyncTime = 0;
mClientStoreMarker = ClientStoreMarker::NotKnown; // no store marker, so download everything
DeleteAllLocations();
DeleteAllIDMaps();
Expand Down Expand Up @@ -3391,17 +3391,14 @@ bool BackupDaemon::SerializeStoreObjectInfo(box_time_t theLastSyncTime,
// --------------------------------------------------------------------------
//
// Function
// Name: BackupDaemon::DeserializeStoreObjectInfo(
// box_time_t & theLastSyncTime,
// box_time_t & theNextSyncTime)
// Name: BackupDaemon::DeserializeStoreObjectInfo()
// Purpose: Deserializes remote directory and file information
// from a stream of bytes, using an Archive
// abstraction.
// Created: 2005/04/11
//
// --------------------------------------------------------------------------
bool BackupDaemon::DeserializeStoreObjectInfo(box_time_t & theLastSyncTime,
box_time_t & theNextSyncTime)
bool BackupDaemon::DeserializeStoreObjectInfo()
{
//
//
Expand Down Expand Up @@ -3501,8 +3498,8 @@ bool BackupDaemon::DeserializeStoreObjectInfo(box_time_t & theLastSyncTime,
// this is it, go at it
//
anArchive.Read(mClientStoreMarker);
anArchive.Read(theLastSyncTime);
anArchive.Read(theNextSyncTime);
anArchive.Read(mLastSyncTime);
anArchive.Read(mNextSyncTime);

//
//
Expand Down Expand Up @@ -3582,11 +3579,7 @@ bool BackupDaemon::DeserializeStoreObjectInfo(box_time_t & theLastSyncTime,
BOX_NOTICE("No usable cache, will download directory listings from "
"server.");

DeleteAllLocations();

mClientStoreMarker = ClientStoreMarker::NotKnown;
theLastSyncTime = 0;
theNextSyncTime = 0;
ResetCachedState();

return false;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/bbackupd/BackupDaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public RunStatusProvider, public SysadminNotifier, public BackgroundTask
// client state only
bool SerializeStoreObjectInfo(box_time_t theLastSyncTime,
box_time_t theNextSyncTime) const;
bool DeserializeStoreObjectInfo(box_time_t & theLastSyncTime,
box_time_t & theNextSyncTime);
bool DeserializeStoreObjectInfo();
bool DeleteStoreObjectInfo() const;
BackupDaemon(const BackupDaemon &);

Expand Down

0 comments on commit ad6c791

Please sign in to comment.