Skip to content

Commit c8b49ed

Browse files
committed
Detect temp file deletion by dnx tool and re-download
Since we use the same temp location for files as the dotnet file programs, they might be cleaned up after a period. We were previously not detecting this and just failing to locate the file (since we only download if saved etag didn't match). We now consider a missing local file as an implicit request to --force download and extract again.
1 parent 1c699be commit c8b49ed

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/Core/RemoteRunner.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public async Task<int> RunAsync(string[] args, bool aot, bool force = false)
4646
return 1;
4747
}
4848

49+
var program = Path.Combine(location.TempPath, location.Path ?? "program.cs");
50+
4951
if (contents.StatusCode != HttpStatusCode.NotModified)
5052
{
5153
#if DEBUG
@@ -67,8 +69,26 @@ await AnsiConsole.Status().StartAsync($":open_file_folder: {location} :backhand_
6769

6870
updated = true;
6971
}
72+
else if (!File.Exists(program))
73+
{
74+
// Redownload if etag matches but file was cleared from local cache somehow
75+
contents = await provider.GetAsync(location with { ETag = null });
76+
if (!contents.IsSuccessStatusCode)
77+
{
78+
AnsiConsole.MarkupLine($":cross_mark: Reference [yellow]{location}[/] not found.");
79+
return 1;
80+
}
81+
82+
await contents.ExtractToAsync(location);
83+
84+
if (contents.Headers.ETag?.ToString() is { } newEtag &&
85+
newEtag != config.GetString(toolName, location.ToString(), "etag"))
86+
{
87+
config = config.SetString(toolName, location.ToString(), "etag", newEtag);
88+
updated = true;
89+
}
90+
}
7091

71-
var program = Path.Combine(location.TempPath, location.Path ?? "program.cs");
7292
if (!File.Exists(program))
7393
{
7494
if (location.Path is not null)

0 commit comments

Comments
 (0)