Skip to content

Commit 14e008e

Browse files
author
Vadim Belov
committed
Add compression algorithm to UploadedHash and migrations
Added CompressionAlgorithm property to UploadedHash entity and updated BackupRunner to set it. Introduced new EF Core migrations for Postgres and Sqlite to add the compression_algorithm column to uploaded_hashes. Updated model snapshots and included migration designer files.
1 parent 2a9253a commit 14e008e

9 files changed

Lines changed: 1178 additions & 4 deletions

src/Octockup.Server/Controllers/BackupController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public async Task<IActionResult> GetServerBackup([FromQuery] bool includeFiles =
9898

9999
Response.ContentType = "application/octet-stream";
100100
Response.Headers.ContentDisposition =
101-
$"attachment; filename=\"server-backup-{userId}.octockup\"";
101+
$"attachment; filename=\"server-backup-{userId}.{CompressionHelpers.Extension}.oct\"";
102102

103103
await using var compressedStream = CompressionHelpers.CreateCompressionStream(Response.Body);
104104

src/Octockup.Server/Database/UploadedHash.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using EasyExtensions.EntityFrameworkCore.Abstractions;
2+
using EasyExtensions.Models.Enums;
23
using Microsoft.EntityFrameworkCore;
34
using System.ComponentModel.DataAnnotations.Schema;
45

@@ -21,6 +22,9 @@ public class UploadedHash : BaseEntity<Guid>
2122
[Column("original_size")]
2223
public long OriginalSize { get; set; }
2324

25+
[Column("compression_algorithm")]
26+
public CompressionAlgorithm CompressionAlgorithm { get; set; }
27+
2428
public virtual Module Module { get; set; } = null!;
2529
}
2630
}

src/Octockup.Server/Jobs/BackupRunner.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ private async Task EnsureUploadedHashRecordedAsync(
437437
StoredSize = storedSize,
438438
OriginalSize = originalSize,
439439
ModuleId = storageModuleId,
440+
CompressionAlgorithm = CompressionHelpers.Algorithm
440441
};
441442
_pendingUploadedHashes.Add(uploadedHash);
442443
}

0 commit comments

Comments
 (0)