Skip to content

Commit 7464aff

Browse files
committed
chore: retry immediately on first exception
1 parent 57f3a83 commit 7464aff

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Docfx.Common/FileAbstractLayer/ManifestFileWriter.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,18 @@ public override Stream Create(RelativePath file)
5959
catch (IOException e) when ((e.HResult & 0x0000FFFF) == 32) // ERROR_SHARING_VIOLATION: 0x80070020
6060
{
6161
// If retry failed 3 times. throw exception
62-
if (++retryCount > 3)
62+
if (retryCount > 3)
6363
throw;
6464

65-
var sleepDelay = 500 * retryCount;
66-
6765
var message = FileLockCheck.GetLockingProcessNames(path);
6866
if (string.IsNullOrEmpty(message))
6967
message = "File is locked by other process";
7068

69+
var sleepDelay = 500 * retryCount; // Retry immediately on first exception.
7170
Logger.LogWarning($"{message}. Retry after {sleepDelay}[ms]", file: path, code: WarningCodes.Build.LockedFile);
72-
Thread.Sleep(500 * retryCount);
71+
Thread.Sleep(sleepDelay);
72+
73+
++retryCount;
7374
goto Retry;
7475
}
7576
}

0 commit comments

Comments
 (0)