-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This app removes file duplicates in specified folder via storing them into backup folder (3rd input parameter).
Run it from terminal. Examples:
- UniqueFiles.ConsoleApp.exe h --- show user manual
- UniqueFiles.ConsoleApp.exe p D:\source D:\backup --- clean up source and store duplicates in backup; preserve empty folders inside source
- UniqueFiles.ConsoleApp.exe e D:\source --- clean up source, store duplicates in source\bkp and erase empty folders inside source
ConsoleApp is .NET Core application - publish it as standalone if you do not have .NET Core on target machine. Output should be of size approximately 80 MB.
ConsoleFrameworkApp is .NET Framework application - just build and copy bin\Debug or bin\Release content onto target machine.
Top level abstraction is a ITransaction interface. It's a Command which sets up all components and triggers source folder cleaning process. It's useful as initially it was not decided whether empty sub folders should be removed or not.
Each ITransaction descendant instance delegates a part of whole work to BackupDirectoryManager and DuplicateCleaner entities. The first one creates/removes (if there are no duplicates) backup folder. The later one goes through all sub-folders of source folder and triggers each file processing.
IUniqueFilesRegistry and IBackedUpFilesRegistry are introduced to help us decide what should be done with a file. The first one is simply a wrapped HashSet (which allows to check if the file is unique). The later is a Dictionary with Task based mechanism of files moving from one location to another. It also provides primitive synchronization mechanism for entities which delete empty folders (all files should be moved before we try to delete a folder).
DirectoryProvider filters out backup folder to avoid redundant work and infinite loops (when it's a sub-folder with respect to a root one).