Skip to content

Commit f15ba14

Browse files
committed
Flush uploaded hashes after backup; remove chunk exists check
Added a flush of pending uploaded hashes in the backup job's cleanup process to ensure all hashes are persisted after execution. Removed the logic that checked for chunk existence in storage and the database before uploading, so chunks are now always uploaded without prior existence verification. Errors during hash flush are logged but do not interrupt cleanup.
1 parent 250fef5 commit f15ba14

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/Octockup.Server/Jobs/BackupRunner.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ public async Task RunAsync(Schedule schedule, CancellationToken cancellationToke
108108
}
109109
finally
110110
{
111+
try
112+
{
113+
await FlushUploadedHashesAsync(CancellationToken.None);
114+
}
115+
catch (Exception flushEx)
116+
{
117+
logger.LogError(flushEx, "Failed to flush pending uploaded hashes after backup execution");
118+
}
119+
111120
await report.DisposeAsync();
112121
}
113122
}
@@ -355,18 +364,7 @@ private async Task<int> ProcessFileAsync(
355364

356365
long storedSize = 0;
357366
string path = ScheduleHelpers.SplitPlainHash(hash, storage.PathSeparator);
358-
bool exists = await storage.ExistsAsync(path, cancellationToken) ?? false;
359367
CompressionAlgorithm algorithm;
360-
if (exists)
361-
{
362-
bool recordedInDb = await dbContext.UploadedHashes
363-
.AsNoTracking()
364-
.AnyAsync(x => x.Hash == hash && x.ModuleId == schedule.Backup.StorageId, cancellationToken);
365-
if (!recordedInDb)
366-
{
367-
throw new InvalidOperationException($"Chunk {shortHash} for file {file.Name} already exists in storage according to ExistsAsync check, but was not found in DB. Hash: {hash}, Path: {path}");
368-
}
369-
}
370368
string size = $"{(chunkLength / (1024.0 * 1024.0)):F2} MB";
371369
logger.LogInformation("Uploading chunk {shortHash} for file {FileName}, size: {size}", shortHash, file.Name, size);
372370

0 commit comments

Comments
 (0)