fix: recording ID
This commit is contained in:
@ -20,4 +20,4 @@ public interface IDvrStore
|
|||||||
Task<List<Guid>> DeleteRecordings(UserStream stream);
|
Task<List<Guid>> DeleteRecordings(UserStream stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record UploadResult(Uri Result, double Duration);
|
public record UploadResult(Guid Id, Uri Result, double Duration);
|
||||||
|
@ -82,12 +82,12 @@ public class S3DvrStore(Config config, HttpClient httpClient, ILogger<S3DvrStore
|
|||||||
tsDownload.TotalMilliseconds,
|
tsDownload.TotalMilliseconds,
|
||||||
tsProbe.TotalMilliseconds, tsUpload.TotalMilliseconds);
|
tsProbe.TotalMilliseconds, tsUpload.TotalMilliseconds);
|
||||||
|
|
||||||
return new(ub.Uri, probe.Duration.TotalSeconds);
|
return new(recordingId, ub.Uri, probe.Duration.TotalSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Guid>> DeleteRecordings(UserStream stream)
|
public async Task<List<Guid>> DeleteRecordings(UserStream stream)
|
||||||
{
|
{
|
||||||
var deleted = new List<Guid>();
|
var deleted = new HashSet<Guid>();
|
||||||
foreach (var batch in stream.Recordings.Select((a, i) => (Batch: i / 100, Item: a)).GroupBy(a => a.Batch))
|
foreach (var batch in stream.Recordings.Select((a, i) => (Batch: i / 100, Item: a)).GroupBy(a => a.Batch))
|
||||||
{
|
{
|
||||||
var res = await _client.DeleteObjectsAsync(new()
|
var res = await _client.DeleteObjectsAsync(new()
|
||||||
@ -96,17 +96,30 @@ public class S3DvrStore(Config config, HttpClient httpClient, ILogger<S3DvrStore
|
|||||||
Objects = batch.Select(a => new KeyVersion()
|
Objects = batch.Select(a => new KeyVersion()
|
||||||
{
|
{
|
||||||
Key = $"{stream.Id}/{a.Item.Id}.ts"
|
Key = $"{stream.Id}/{a.Item.Id}.ts"
|
||||||
}).ToList()
|
}).Concat(batch.Select(a =>
|
||||||
|
{
|
||||||
|
var url = new Uri(a.Item.Url);
|
||||||
|
return new KeyVersion
|
||||||
|
{
|
||||||
|
Key = url.AbsolutePath.Replace($"/${_config.BucketName}", string.Empty)
|
||||||
|
};
|
||||||
|
})).ToList()
|
||||||
});
|
});
|
||||||
deleted.AddRange(res.DeletedObjects.Select(a => Guid.Parse(Path.GetFileNameWithoutExtension(a.Key))));
|
foreach (var d in res.DeletedObjects)
|
||||||
|
{
|
||||||
|
deleted.Add(Guid.Parse(Path.GetFileNameWithoutExtension(d.Key)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await _client.DeleteObjectAsync(new()
|
if (deleted.Count == stream.Recordings.Count)
|
||||||
{
|
{
|
||||||
BucketName = _config.BucketName,
|
await _client.DeleteObjectAsync(new()
|
||||||
Key = $"{stream.Id}/"
|
{
|
||||||
});
|
BucketName = _config.BucketName,
|
||||||
|
Key = $"{stream.Id}/"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return deleted;
|
return deleted.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -195,6 +195,7 @@ public class NostrStreamManager : IStreamManager
|
|||||||
var result = await _dvrStore.UploadRecording(_context.UserStream, segment);
|
var result = await _dvrStore.UploadRecording(_context.UserStream, segment);
|
||||||
_context.Db.Recordings.Add(new()
|
_context.Db.Recordings.Add(new()
|
||||||
{
|
{
|
||||||
|
Id = result.Id,
|
||||||
UserStreamId = _context.UserStream.Id,
|
UserStreamId = _context.UserStream.Id,
|
||||||
Url = result.Result.ToString(),
|
Url = result.Result.ToString(),
|
||||||
Duration = result.Duration,
|
Duration = result.Duration,
|
||||||
|
Reference in New Issue
Block a user