fix disposed semaphores

This commit is contained in:
rootdarkarchon
2023-11-18 17:41:18 +01:00
parent a1573ad2c3
commit 5a4010cb8a

View File

@@ -239,12 +239,22 @@ public class ServerFilesController : ControllerBase
return BadRequest();
}
finally
{
try
{
fileLock?.Release();
fileLock?.Dispose();
}
catch (ObjectDisposedException)
{
// it's disposed whatever
}
finally
{
_fileUploadLocks.TryRemove(hash, out _);
}
}
}
[HttpPost(MareFiles.ServerFiles_UploadMunged + "/{hash}")]
[RequestSizeLimit(200 * 1024 * 1024)]
@@ -326,12 +336,22 @@ public class ServerFilesController : ControllerBase
return BadRequest();
}
finally
{
try
{
fileLock?.Release();
fileLock?.Dispose();
}
catch (ObjectDisposedException)
{
// it's disposed whatever
}
finally
{
_fileUploadLocks.TryRemove(hash, out _);
}
}
}
private static void MungeBuffer(Span<byte> buffer)
{
@@ -421,10 +441,20 @@ public class ServerFilesController : ControllerBase
return BadRequest();
}
finally
{
try
{
fileLock?.Release();
fileLock?.Dispose();
}
catch (ObjectDisposedException)
{
// it's disposed whatever
}
finally
{
_fileUploadLocks.TryRemove(hash, out _);
}
}
}
}