From 5f2046791ae4e7e0593ce15d0cd9e4bcc799298b Mon Sep 17 00:00:00 2001 From: Anna Date: Thu, 22 Aug 2024 07:11:06 -0400 Subject: [PATCH] fix: copy files instead of moving them --- DownloadTask.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DownloadTask.cs b/DownloadTask.cs index e2ec7d1..c1beecc 100644 --- a/DownloadTask.cs +++ b/DownloadTask.cs @@ -58,12 +58,12 @@ internal class DownloadTask : IDisposable { private bool SupportsHardLinks { get; set; } /// - /// A mapping of existing file paths to their hashes. + /// A mapping of existing file paths to their hashes. Paths are relative. /// private IReadOnlyDictionary ExistingPathHashes { get; set; } = new Dictionary(); /// - /// A mapping of existing hashes to their file paths. + /// A mapping of existing hashes to their file paths. Paths are relative. /// private IReadOnlyDictionary ExistingHashPaths { get; set; } = new Dictionary(); @@ -740,7 +740,7 @@ internal static string[] GetOutputPaths(IReadOnlyCollection> files private async Task DuplicateFile(string filesDir, IEnumerable outputPaths, string path) { if (!this.SupportsHardLinks) { - // if hard links aren't supported, move the path to the first output + // if hard links aren't supported, copy the path to the first output // path var firstPath = outputPaths.FirstOrDefault(); if (firstPath == null) { @@ -753,7 +753,7 @@ private async Task DuplicateFile(string filesDir, IEnumerable outputPath } // ReSharper disable once AccessToModifiedClosure - Plugin.Resilience.Execute(() => File.Move(path, dest)); + Plugin.Resilience.Execute(() => File.Copy(path, dest)); path = dest; return; } @@ -842,6 +842,7 @@ private async Task DownloadFile(Uri baseUri, string filesPath, string[] outputPa // find an existing path that has this hash if (this.ExistingHashPaths.TryGetValue(hash, out var validPath)) { + validPath = Path.Join(filesPath, validPath); goto Duplicate; }