diff --git a/Tools/RemoteSynchronization/Program.cs b/Tools/RemoteSynchronization/Program.cs index 7a97bedb3..82b1f88d2 100644 --- a/Tools/RemoteSynchronization/Program.cs +++ b/Tools/RemoteSynchronization/Program.cs @@ -45,6 +45,11 @@ namespace RemoteSynchronization private const bool DEFAULT_RETENTION = false; private const bool DEFAULT_CONFIRM = false; + /// + /// Main entry point for the tool. + /// + /// The commandline arguments + /// 0 on success, -1 on abort, and the number of errors encountered otherwise. public static async Task Main(string[] args) { var src_arg = new Argument(name: "backend_src", description: "The source backend string"); @@ -102,6 +107,13 @@ destination will be verified before being overwritten (if they seemingly match). return await root_cmd.InvokeAsync(args); } + /// + /// The main logic of the tool. + /// + /// The connection string for the source backend. + /// The connection string for the destination backend. + /// Various options for the tool + /// The return code for the main entry; 0 on success. private static async Task Run(string src, string dst, Dictionary options) { // Parse the known options for this tool @@ -238,6 +250,16 @@ destination will be verified before being overwritten (if they seemingly match). // introduce these checks as a post processing step? Especially the database consistency check, as that is often recreated from the index files. // TODO This tool shouldn't handle it, but for convenience, it should support making the seperate call to the regular Duplicati on the destination backend, which alread carries this functionality. + /// + /// Copies the files from one backend to another. + /// The files are copied one by one, and each file is verified after uploading if the verify flag is set. + /// + /// The source backend. + /// The destination backend. + /// The files that will be copied. + /// Flag for whether destructive actions (writes) should be printed rather than performed. Downloads (reads) are still being performed. + /// Flag for whether to verify each upload to the destination backend. + /// A tuple holding the number of succesful copies and a List of the files that failed. private static async Task<(long, IEnumerable)> CopyAsync(IStreamingBackend b_src, IStreamingBackend b_dst, IEnumerable files, bool dry_run, bool verify) { long successful_copies = 0; @@ -279,6 +301,13 @@ destination will be verified before being overwritten (if they seemingly match). return (successful_copies, errors); } + /// + /// Deletes the files from a backend. + /// + /// The backend to delete the files from. + /// The files to delete. + /// Flag for whether the deletion should be printed rather than performed. + /// The number of successful deletions. private static async Task DeleteAsync(IStreamingBackend b, IEnumerable files, bool dry_run) { long successful_deletes = 0; @@ -304,6 +333,12 @@ destination will be verified before being overwritten (if they seemingly match). return successful_deletes; } + /// + /// Creates an option that allows multiple tokens and multiple arguments per token. + /// + /// The aliases for the option. + /// The description for the option. + /// The created option. private static Option> OptionWithMultipleTokens(string[] aliases, string description) { return new Option>(aliases: aliases, description: description) @@ -313,6 +348,16 @@ destination will be verified before being overwritten (if they seemingly match). }; } + /// + /// Prepares the lists of files to copy, delete and verify. + /// The files to copy are the files that are not in the destination, have a different size or have a more recent modification date. + /// The files to delete are the files that are found in the destination but not found in the source. + /// The files to verify are the files that are found in both the source and the destination, and that have the same size and modification date. + /// + /// The source backend. + /// The destination backend. + /// Flag for whether to force the synchronization. + /// A tuple of Lists each holding the files to copy, delete and verify. private static (IEnumerable, IEnumerable, IEnumerable) PrepareFileLists(IStreamingBackend b_src, IStreamingBackend b_dst, bool force) { var files_src = b_src.List(); @@ -376,6 +421,14 @@ destination will be verified before being overwritten (if they seemingly match). return (to_copy, to_delete.Select(x => lookup_dst[x]), to_verify); } + /// + /// Renames the files in a backend. + /// The renaming is done by deleting the file and re-uploading it with a new name. + /// + /// The backend to rename the files in. + /// The files to rename. + /// Flag for whether the renaming should be printed rather than performed. + /// The number of successful renames. private static async Task RenameAsync(IStreamingBackend b, IEnumerable files, bool dry_run) { long successful_renames = 0; @@ -406,6 +459,14 @@ destination will be verified before being overwritten (if they seemingly match). return successful_renames; } + /// + /// Verifies the files in the destination backend. + /// The verification is done by downloading the files from the destination backend and comparing them to the source files. + /// + /// The source backend. + /// The destination backend. + /// The files to verify. + /// A list of the files that failed verification. private static async Task> VerifyAsync(IStreamingBackend b_src, IStreamingBackend b_dst, IEnumerable files) { var errors = new List();