Esempio n. 1
0
        private async Task AddDirectory(Vault vault, IProgress <ProgressReport> progress)
        {
            var allFiles = NDirectory.GetAllFilesRecursive(ToAddPath);

            var report = new ProgressReport(allFiles.Count);

            await allFiles.ParallelForEachAsync(async file =>
            {
                var pathToFile = NPath.GetRelativePathToFile(ToAddPath, file);

                try
                {
                    await vault.AddFileAsync(file, pathToFile);
                }
                catch (Exception e)
                {
                    report.IncrementFailedFiles();
                    Log.Error(string.Format(Strings.AddCommandAsync_AddDirectory_Error_with_file__0____1_, file, e));
                }
                finally
                {
                    report.IncrementModifiedFiles();
                    progress.Report(report);
                }
            }, 0);

            Console.WriteLine();
            Notifier.Success(string.Format(Strings.AddCommandAsync_AddDirectory_Added_directory__0__to_vault, ToAddPath));
        }