Skip to content

Commit f32d247

Browse files
author
Vadim Belov
committed
Remove compression algorithm check on chunk upload
Previously, uploading a chunk with a matching hash and storage module ID but a different compression algorithm would throw an exception. Now, the code simply returns if a matching chunk is found, regardless of the compression algorithm used.
1 parent f9af6fb commit f32d247

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/Octockup.Server/Jobs/BackupRunner.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,11 @@ private async Task EnsureUploadedHashRecordedAsync(
451451
CompressionAlgorithm algorithm,
452452
CancellationToken cancellationToken)
453453
{
454-
var foundChunk = await dbContext.UploadedHashes
454+
bool chunkRecorded = await dbContext.UploadedHashes
455455
.AsNoTracking()
456-
.FirstOrDefaultAsync(x => x.Hash == hash && x.ModuleId == storageModuleId, cancellationToken);
457-
if (foundChunk != null)
456+
.AnyAsync(x => x.Hash == hash && x.ModuleId == storageModuleId, cancellationToken);
457+
if (chunkRecorded)
458458
{
459-
if (foundChunk.CompressionAlgorithm != algorithm)
460-
{
461-
throw new InvalidOperationException($"Hash {hash} for storage module {storageModuleId} already exists with different compression algorithm. " +
462-
$"Existing: {foundChunk.CompressionAlgorithm}, New: {algorithm}");
463-
}
464459
return;
465460
}
466461

0 commit comments

Comments
 (0)