Skip to content

Commit

Permalink
Try to fix reset-project Playwright tests
Browse files Browse the repository at this point in the history
We believe the failures in the Playwright tests are due to NFS caching
the directory entry, and thus not noticing that the directory has new
contents, resulting in Mercurial thinking the directory is still empty
for some time after the zip file upload has completed. It is possible to
force NFS to refresh its cache of a directory by doing opendir() and
closedir() on that directory. I don't know if C#'s Directory.GetFiles
method, which uses the openat() system call rather than opendir() and
closedir(), will have the same effect — but it's worth a try.
  • Loading branch information
rmunn committed May 7, 2024
1 parent 3e12b8a commit a671e0c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/LexBoxApi/Services/HgService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public async Task ResetRepo(string code)
await SoftDeleteRepo(code, $"{FileUtils.ToTimestamp(DateTimeOffset.UtcNow)}__reset");
//we must init the repo as uploading a zip is optional
tmpRepo.MoveTo(PrefixRepoFilePath(code));
// Force NFS to refresh its directory cache. Discard return value as we don't actually want it.
_ = Directory.GetFiles(PrefixRepoFilePath(code));

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
}

public async Task FinishReset(string code, Stream zipFile)
Expand Down Expand Up @@ -137,6 +139,8 @@ await Task.Run(() =>
// Now we're ready to move the new repo into place, replacing the old one
await DeleteRepo(code);
tempRepo.MoveTo(PrefixRepoFilePath(code));
// Force NFS to refresh its directory cache. Discard return value as we don't actually want it.
_ = Directory.GetFiles(PrefixRepoFilePath(code));

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
}

/// <summary>
Expand Down

0 comments on commit a671e0c

Please sign in to comment.