Align CI fixtures with camera config and release manifest
This commit is contained in:
1 parent
21084bf00e
commit
0cc950967e
6 files changed
+62
-15
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System.Globalization;
|
||||
using Heimdall.Application.Common;
|
||||
using Heimdall.Domain.Entities;
|
||||
using Heimdall.Infrastructure.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -168,18 +169,32 @@ public class PartitionManagerJob
|
||||
var events = await db.CameraEvents.AsNoTracking()
|
||||
.Where(e => e.OccurredAt >= from && e.OccurredAt < to &&
|
||||
(e.SnapshotObjectKey != null || e.SnapshotThumbObjectKey != null))
|
||||
.OrderBy(e => e.Id).Skip(offset).Take(batchSize).ToListAsync(ct).ConfigureAwait(false);
|
||||
.OrderBy(e => e.Id).Skip(offset).Take(batchSize)
|
||||
.Select(e => new
|
||||
{
|
||||
e.Id, e.SnapshotObjectKey, e.SnapshotThumbObjectKey,
|
||||
e.SnapshotStorageProvider, e.SnapshotStorageRoot,
|
||||
e.SnapshotStorageEndpoint, e.SnapshotStorageBucket
|
||||
}).ToListAsync(ct).ConfigureAwait(false);
|
||||
if (events.Count == 0) break;
|
||||
if (_storage is null) throw new InvalidOperationException("Snapshot storage deletion is unavailable");
|
||||
|
||||
var incomplete = events.FirstOrDefault(e => e.GetSnapshotLocation() is null);
|
||||
if (incomplete is not null)
|
||||
throw new InvalidOperationException($"Snapshot destination is incomplete for event {incomplete.Id}");
|
||||
|
||||
foreach (var group in events.GroupBy(e => e.GetSnapshotLocation()!))
|
||||
await _storage.DeleteBatchAsync(
|
||||
group.SelectMany(e => new[] { e.SnapshotObjectKey, e.SnapshotThumbObjectKey })
|
||||
.OfType<string>().ToArray(), group.Key, ct).ConfigureAwait(false);
|
||||
var objectsByLocation = new Dictionary<StorageLocation, List<string>>();
|
||||
foreach (var ev in events)
|
||||
{
|
||||
if (ev.SnapshotStorageProvider is null)
|
||||
throw new InvalidOperationException($"Snapshot destination is incomplete for event {ev.Id}");
|
||||
var location = new StorageLocation(ev.SnapshotStorageProvider.Value,
|
||||
ev.SnapshotStorageRoot, ev.SnapshotStorageEndpoint, ev.SnapshotStorageBucket);
|
||||
if (!location.IsComplete)
|
||||
throw new InvalidOperationException($"Snapshot destination is incomplete for event {ev.Id}");
|
||||
if (!objectsByLocation.TryGetValue(location, out var keys))
|
||||
objectsByLocation[location] = keys = [];
|
||||
if (ev.SnapshotObjectKey is { } snapshot) keys.Add(snapshot);
|
||||
if (ev.SnapshotThumbObjectKey is { } thumb) keys.Add(thumb);
|
||||
}
|
||||
foreach (var (location, keys) in objectsByLocation)
|
||||
await _storage.DeleteBatchAsync(keys, location, ct).ConfigureAwait(false);
|
||||
|
||||
offset += events.Count;
|
||||
if (events.Count < batchSize) break;
|
||||
|
||||
Reference in new issue
Block a user