Fix incorrect comparison in archive usage metric

This commit is contained in:
Ravi Khadiwala 2024-01-09 13:49:39 -06:00 committed by ravi-signal
parent 323bfd9a6e
commit e934ead85c
2 changed files with 6 additions and 5 deletions

View File

@ -198,13 +198,13 @@ public class BackupManager {
return this.remoteStorageManager.calculateBytesUsed(mediaPrefix)
.thenCompose(usage -> backupsDb
.setMediaUsage(backupUser, usage)
.thenApply(ignored -> usage.bytesUsed()))
.thenApply(ignored -> usage))
.whenComplete((newUsage, throwable) -> {
boolean usageChanged = throwable == null && !newUsage.equals(info.usageInfo());
Metrics.counter(USAGE_RECALCULATION_COUNTER_NAME, "usageChanged", String.valueOf(usageChanged))
.increment();
})
.thenApply(usedSpace -> MAX_TOTAL_BACKUP_MEDIA_BYTES - usedSpace >= mediaLength);
.thenApply(newUsage -> MAX_TOTAL_BACKUP_MEDIA_BYTES - newUsage.bytesUsed() >= mediaLength);
});
}

View File

@ -642,6 +642,7 @@ public class ArchiveController {
String cursor) {}
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/media")
@Operation(summary = "List media objects",