mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-10 20:22:28 +00:00
Make logger a non-static class
This commit is contained in:
parent
c345eeebb9
commit
630b38e7bb
27 changed files with 167 additions and 141 deletions
|
@ -77,24 +77,24 @@ public class ResourcesController : ControllerBase
|
|||
// lbp treats code 409 as success and as an indicator that the file is already present
|
||||
if (FileHelper.ResourceExists(hash)) this.Conflict();
|
||||
|
||||
Logger.LogInfo($"Processing resource upload (hash: {hash})", LogArea.Resources);
|
||||
Logger.Info($"Processing resource upload (hash: {hash})", LogArea.Resources);
|
||||
LbpFile file = new(await readFromPipeReader(this.Request.BodyReader));
|
||||
|
||||
if (!FileHelper.IsFileSafe(file))
|
||||
{
|
||||
Logger.LogWarn($"File is unsafe (hash: {hash}, type: {file.FileType})", LogArea.Resources);
|
||||
Logger.Warn($"File is unsafe (hash: {hash}, type: {file.FileType})", LogArea.Resources);
|
||||
return this.Conflict();
|
||||
}
|
||||
|
||||
string calculatedHash = file.Hash;
|
||||
if (calculatedHash != hash)
|
||||
{
|
||||
Logger.LogWarn
|
||||
Logger.Warn
|
||||
($"File hash does not match the uploaded file! (hash: {hash}, calculatedHash: {calculatedHash}, type: {file.FileType})", LogArea.Resources);
|
||||
return this.Conflict();
|
||||
}
|
||||
|
||||
Logger.LogSuccess($"File is OK! (hash: {hash}, type: {file.FileType})", LogArea.Resources);
|
||||
Logger.Success($"File is OK! (hash: {hash}, type: {file.FileType})", LogArea.Resources);
|
||||
await IOFile.WriteAllBytesAsync(path, file.Data);
|
||||
return this.Ok();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue