Package org.syncany.operations.down
Class FileSystemActionComparator
- java.lang.Object
-
- org.syncany.operations.down.FileSystemActionComparator
-
public class FileSystemActionComparator extends java.lang.Object
Sorts file system actions according to their natural order to prevent scenarios in which a non-empty directory is deleted, ... Sorting necessary: 1. Delete file/symlink actions must happen first 2. New folder actions must happen after delete file/symlink actions, and must be sorted by path, shortest first (within new actions) 3. New file/symlink actions must happen after new folder actions 4. Rename file/symlink actions must happen after new folder actions 5. Delete folder actions must happen last, sorted by path, longest first (within delete actions) a. except if the deleted folder has a name clash with another action (rename/new) in that case, it must happen before the other action No sorting necessary: - Change file/symlink actions can happen anytime - Set attributes actions can happen anytime Cannot happen: - Rename folder - Change folder TODO [medium] NewSymlinkFileSystemAction → NewFile (has no content)
-
-
Constructor Summary
Constructors Constructor Description FileSystemActionComparator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
postCompareSort(java.util.List<FileSystemAction> actions)
Fixes the case in which a folder has been swapped with a file (case 5a, see above) New/Renamed file system actions must happen *after* the file was deleted.void
sort(java.util.List<FileSystemAction> actions)
-
-
-
Constructor Detail
-
FileSystemActionComparator
public FileSystemActionComparator()
-
-
Method Detail
-
sort
public void sort(java.util.List<FileSystemAction> actions)
-
postCompareSort
public void postCompareSort(java.util.List<FileSystemAction> actions)
Fixes the case in which a folder has been swapped with a file (case 5a, see above) New/Renamed file system actions must happen *after* the file was deleted. This method moves new/renamed actions below deleted folder actions. DEL FILE file1.jpg NEW FOLDER folder1 NEW FILE folder1/fileinfolder1.jpg ← No Issue, but needs to be checked NEW FILE folder2 ←←← Issue, because folder2 is deleted below! NEW SYMLINK folder1/symlinkinfolder1.jpg ← No Issue, but needs to be checked REN FILE folder2/fileinfolder2.jpg → folder1/x2.jpg REN SYMLINK folder2/symlinkinfolder2.jpg → folder1/sym2 DEL FOLDER folder2 ←←← New position of "NEW FILE folder2"!
-
-