[backend/drive] Report count of orphaned files removed by storage cleanup job on completion
This commit is contained in:
parent
ead9d90029
commit
79014ec4b7
1 changed files with 4 additions and 1 deletions
|
@ -258,6 +258,7 @@ public class StorageMaintenanceService(
|
||||||
.ToHashSet());
|
.ToHashSet());
|
||||||
|
|
||||||
logger.LogInformation("Loaded {count} files from database.", filenames.Count);
|
logger.LogInformation("Loaded {count} files from database.", filenames.Count);
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
if (options.Value.Local?.Path is { } path && Directory.Exists(path))
|
if (options.Value.Local?.Path is { } path && Directory.Exists(path))
|
||||||
{
|
{
|
||||||
|
@ -271,6 +272,7 @@ public class StorageMaintenanceService(
|
||||||
logger.LogInformation("Would delete {file} from disk, but --dry-run was specified.", file);
|
logger.LogInformation("Would delete {file} from disk, but --dry-run was specified.", file);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
count++;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Delete(file);
|
File.Delete(file);
|
||||||
|
@ -295,6 +297,7 @@ public class StorageMaintenanceService(
|
||||||
logger.LogInformation("Would delete {file} from object storage, but --dry-run was specified.", key);
|
logger.LogInformation("Would delete {file} from object storage, but --dry-run was specified.", key);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
count++;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await objectStorageSvc.RemoveFilesAsync(key);
|
await objectStorageSvc.RemoveFilesAsync(key);
|
||||||
|
@ -307,6 +310,6 @@ public class StorageMaintenanceService(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogInformation("Finished scanning for orphaned files.");
|
logger.LogInformation("Finished removing {count} orphaned files.", count);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue