Sorts file system actions according to their natural order to prevent scenarios
in which a non-empty directory is deleted, ...
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
- Rename folder
- Change folder
TODO [medium] NewSymlinkFileSystemAction --> NewFile (has no content)
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"!