better handle proxy cache rename error

This commit is contained in:
Robert Paciorek 2024-02-17 00:28:40 +00:00
parent b7720af330
commit 2dfb5fd1b8

View File

@ -107,7 +107,13 @@ public class AssetMiddleware
}
// after successfully write data to temporary file, rename it to proper asset filename
try {
File.Move(filePathTmp, filePath);
} catch (System.IO.IOException) {
// this can happen for example if two clients request the same file in the same time
// TODO: avoid redundant download in those cases
File.Delete(filePathTmp);
}
} else {
await inputStream.CopyToAsync(context.Response.Body);
}