Skip to content

Commit

Permalink
When same Url file, different target path, does not update multiple
Browse files Browse the repository at this point in the history
Make sure we don't skip processing of updates for files with same URL but different target path.

Fixes #54
  • Loading branch information
kzu committed Oct 27, 2021
1 parent b01c713 commit 3190be0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/File/AddCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override async Task<int> ExecuteAsync()
var length = Files.Select(x => x.Path).Max(x => x.Length) + 1;
void Write(string s) => Console.Write(s + new string(' ', length - s.Length));

var processed = new HashSet<string>();
var processed = new Dictionary<(string, Uri), object?>();

// TODO: allow configuration to provide HTTP headers, i.e. auth?
foreach (var file in Files)
Expand Down Expand Up @@ -62,7 +62,7 @@ public override async Task<int> ExecuteAsync()
}
}

if (processed.Contains(uri.ToString()))
if (processed.ContainsKey((file.Path, uri)))
continue;

var etag = file.ETag ?? section.GetString("etag");
Expand All @@ -72,7 +72,7 @@ public override async Task<int> ExecuteAsync()

try
{
processed.Add(uri.ToString());
processed.Add((file.Path, uri), null);
var request = new HttpRequestMessage(DryRun ? HttpMethod.Head : HttpMethod.Get, uri);
// Propagate previous values, used in GitHubRawHandler to optimize SHA retrieval
if (etag != null)
Expand Down Expand Up @@ -180,7 +180,7 @@ public override async Task<int> ExecuteAsync()
// Track all files as already processed to skip duplicate processing from
// existing expanded list.
foreach (var repoFile in repoFiles)
processed.Add(repoFile.Uri!.ToString());
processed.Add((repoFile.Path, repoFile.Uri!), null);

result = await command.ExecuteAsync();

Expand Down

0 comments on commit 3190be0

Please sign in to comment.