summaryrefslogtreecommitdiff
path: root/lib/versioning.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:27:42 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:27:42 +0200
commitb916407a2a06f8452e82b74dc44c54acbcc572b0 (patch)
tree46358e0bb035fca0f42edb4b5b8aa5f1613814af /lib/versioning.cpp
parent5.20 (diff)
downloadFreeFileSync-b916407a2a06f8452e82b74dc44c54acbcc572b0.tar.gz
FreeFileSync-b916407a2a06f8452e82b74dc44c54acbcc572b0.tar.bz2
FreeFileSync-b916407a2a06f8452e82b74dc44c54acbcc572b0.zip
5.21
Diffstat (limited to 'lib/versioning.cpp')
-rw-r--r--lib/versioning.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/lib/versioning.cpp b/lib/versioning.cpp
index a6458196..65373499 100644
--- a/lib/versioning.cpp
+++ b/lib/versioning.cpp
@@ -120,23 +120,22 @@ void moveItemToVersioning(const Zstring& fullName, //throw FileError
//move source to target across volumes
-//no need to check if: - super-directories of target exist - source exists
+//no need to check if: - super-directories of target exist - source exists: done by moveItemToVersioning()
//if target already exists, it is overwritten, even if it is a different type, e.g. a directory!
template <class Function>
void moveObject(const Zstring& sourceFile, //throw FileError
const Zstring& targetFile,
Function copyDelete) //throw FileError; fallback if move failed
{
- assert(!dirExists(sourceFile) || symlinkExists(sourceFile)); //we process files and symlinks only
+ assert(fileExists(sourceFile) || symlinkExists(sourceFile) || !somethingExists(sourceFile)); //we process files and symlinks only
auto removeTarget = [&]
{
//remove target object
- if (fileExists(targetFile)) //file or symlink
- removeFile(targetFile); //throw FileError
- else if (dirExists(targetFile)) //directory or symlink
+ if (dirExists(targetFile)) //directory or dir-symlink
removeDirectory(targetFile); //throw FileError; we do not expect targetFile to be a directory in general => no callback required
- //else assert(false); -> may simply not exist if ErrorDifferentVolume!
+ else //file or (broken) file-symlink
+ removeFile(targetFile); //throw FileError
};
//first try to move directly without copying
@@ -212,17 +211,10 @@ private:
virtual HandleLink onSymlink(const Zchar* shortName, const Zstring& fullName, const SymlinkInfo& details)
{
- switch (getSymlinkType(fullName))
- {
- case SYMLINK_TYPE_DIR:
- dirs_.push_back(shortName);
- break;
-
- case SYMLINK_TYPE_FILE:
- case SYMLINK_TYPE_UNKNOWN:
- files_.push_back(shortName);
- break;
- }
+ if (dirExists(fullName)) //dir symlink
+ dirs_.push_back(shortName);
+ else //file symlink, broken symlink
+ files_.push_back(shortName);
return LINK_SKIP;
}
bgstack15