Switch to JWT authentication (#19)

* switch to jwt authentication

* fix delete files

* adjust saving of deletion of all files

* update api to main/jwt

Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
rootdarkarchon
2023-01-02 17:07:34 +01:00
committed by GitHub
parent bdd8830c8e
commit 5f0c12ecfa
15 changed files with 140 additions and 101 deletions

View File

@@ -78,14 +78,16 @@ public class GrpcFileService : FileService.FileServiceBase
try
{
var fi = FilePathUtil.GetFileInfoForHash(_basePath, hash);
fi?.Delete();
var file = await _mareDbContext.Files.SingleOrDefaultAsync(f => f.Hash == hash).ConfigureAwait(false);
if (file != null)
if (file != null && fi != null)
{
_mareDbContext.Files.Remove(file);
await _mareDbContext.SaveChangesAsync().ConfigureAwait(false);
_metricsClient.DecGauge(MetricsAPI.GaugeFilesTotal, fi == null ? 0 : 1);
_metricsClient.DecGauge(MetricsAPI.GaugeFilesTotalSize, fi?.Length ?? 0);
fi?.Delete();
}
}
catch (Exception ex)
@@ -94,7 +96,6 @@ public class GrpcFileService : FileService.FileServiceBase
}
}
await _mareDbContext.SaveChangesAsync().ConfigureAwait(false);
return new Empty();
}
}