From ecb1524f8da7901338b263384fed3c612f117b4c Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:22:36 +0200 Subject: 5.11 --- lib/versioning.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib/versioning.h') diff --git a/lib/versioning.h b/lib/versioning.h index b025511b..3e0dd33c 100644 --- a/lib/versioning.h +++ b/lib/versioning.h @@ -13,6 +13,7 @@ #include #include #include +#include "../structures.h" namespace zen { @@ -25,19 +26,20 @@ struct CallbackMoveFile; - creates missing intermediate directories - does not create empty directories - handles symlinks - - ignores already existing target files/dirs (support retry) - => (unlikely) risk of data loss: race-condition if two FFS instances start at the very same second and process the same filename!! + - replaces already existing target files/dirs (supports retry) + => (unlikely) risk of data loss for naming convention "versioning": + race-condition if two FFS instances start at the very same second OR multiple folder pairs process the same filename!! */ class FileVersioner { public: FileVersioner(const Zstring& versioningDirectory, //throw FileError - const TimeComp& timeStamp, - int versionCountLimit) : //max versions per file; < 0 := no limit + VersioningStyle versioningStyle, + const TimeComp& timeStamp) : //max versions per file; < 0 := no limit + versioningStyle_(versioningStyle), versioningDirectory_(versioningDirectory), - timeStamp_(formatTime(Zstr("%Y-%m-%d %H%M%S"), timeStamp)), //e.g. "2012-05-15 131513" - versionCountLimit_(versionCountLimit) + timeStamp_(formatTime(Zstr("%Y-%m-%d %H%M%S"), timeStamp)) //e.g. "2012-05-15 131513" { if (timeStamp_.size() != 17) //formatTime() returns empty string on error; unexpected length: e.g. problem in year 10000! throw FileError(_("Failure to create time stamp for versioning:") + L" \'" + timeStamp_ + L"\'"); @@ -46,14 +48,14 @@ public: void revisionFile(const Zstring& sourceFile, const Zstring& relativeName, CallbackMoveFile& callback); //throw FileError void revisionDir (const Zstring& sourceDir, const Zstring& relativeName, CallbackMoveFile& callback); //throw FileError - void limitVersions(std::function updateUI); //throw FileError; call when done revisioning! + //void limitVersions(std::function updateUI); //throw FileError; call when done revisioning! private: + const VersioningStyle versioningStyle_; const Zstring versioningDirectory_; const Zstring timeStamp_; - const int versionCountLimit_; - std::vector fileRelNames; //store list of revisioned file and symlink relative names for limitVersions() + //std::vector fileRelNames; //store list of revisioned file and symlink relative names for limitVersions() }; -- cgit