From a620a93fe0d3f0f5848ec35cfb9678fd3a8a9675 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Fri, 10 May 2024 16:14:32 +0700 Subject: [PATCH] Try calling `sync` before WaitForRepoEmptyState Hopefully this will make the NFS client flush its buffers. --- backend/LexBoxApi/Services/HgService.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/LexBoxApi/Services/HgService.cs b/backend/LexBoxApi/Services/HgService.cs index 9320010a0..847615f58 100644 --- a/backend/LexBoxApi/Services/HgService.cs +++ b/backend/LexBoxApi/Services/HgService.cs @@ -69,6 +69,7 @@ await Task.Run(() => { InitRepoAt(new DirectoryInfo(PrefixRepoFilePath(code))); }); + await Process.Start("sync").WaitForExitAsync(); // TODO: Put behind an OS check so we don't break Windows await WaitForRepoEmptyState(code, RepoEmptyState.Empty); } @@ -107,6 +108,7 @@ 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)); + await Process.Start("sync").WaitForExitAsync(); // TODO: Put behind an OS check so we don't break Windows // await InvalidateDirCache(code); // TODO 789: Sometimes NFS hasn't finished the MoveTo above! So we need to find a way to wait until InvalidateDirCache sees an *empty* repo... await WaitForRepoEmptyState(code, RepoEmptyState.Empty); } @@ -143,6 +145,7 @@ await Task.Run(() => await DeleteRepo(code); tempRepo.MoveTo(PrefixRepoFilePath(code)); // await InvalidateDirCache(code); + await Process.Start("sync").WaitForExitAsync(); // TODO: Put behind an OS check so we don't break Windows await WaitForRepoEmptyState(code, RepoEmptyState.NonEmpty); // TODO: Either catch the case where someone uploaded a .zip of an empty .hg repo, or set a timeout in WaitForRepoEmptyState }