scanner improvements + playback ux
This commit is contained in:
@@ -32,15 +32,15 @@ public class AZKiRpcService(MediaService mediaService) : RPC.AZKi.AZKiBase
|
||||
{
|
||||
CameraId = c.Key,
|
||||
};
|
||||
result.Images.AddRange(images);
|
||||
result.Videos.AddRange(videos);
|
||||
result.Images.AddRange(images.OrderBy(i => i.Date));
|
||||
result.Videos.AddRange(videos.OrderBy(i => i.Date));
|
||||
return result;
|
||||
});
|
||||
var playback = new PlaybackInfo
|
||||
{
|
||||
Date = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(from),
|
||||
};
|
||||
playback.Channels.AddRange(channels);
|
||||
playback.Channels.AddRange(channels.OrderBy(c => c.CameraId));
|
||||
return playback;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ using FFMpegCore;
|
||||
using MaybeError;
|
||||
using MaybeError.Errors;
|
||||
|
||||
using SharpCompress.Common;
|
||||
|
||||
using SixLabors.ImageSharp;
|
||||
|
||||
using System.Collections.Frozen;
|
||||
@@ -55,11 +57,17 @@ public class FileScannerService(MediaService mediaService, IConfiguration config
|
||||
{
|
||||
var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
|
||||
var existingFiles = await mediaService.GetExistingFilePathsAsync(cancellationToken);
|
||||
var upToDateFiles = existingFiles.Where(e => e.Value == MediaEntry.CUR_VERSION)
|
||||
.Select(e => e.Key)
|
||||
.ToFrozenSet();
|
||||
var filesToProcess = files.Where(f => !upToDateFiles.Contains(Path.GetRelativePath(path, f))).ToArray();
|
||||
var total = 0;
|
||||
foreach (var chunk in files.Chunk(50))
|
||||
var prog = 0;
|
||||
foreach (var chunk in filesToProcess.Chunk(50))
|
||||
{
|
||||
prog += chunk.Length;
|
||||
total += await ScanFileChunkAsync(path, chunk, existingFiles, cancellationToken);
|
||||
logger.LogInformation("Added {updated} of {count} [{percentage}%]", total, files.Length, Math.Round(((float)total/ files.Length) * 100));
|
||||
logger.LogInformation("Added {updated} of {count} [{percentage}%]", total, filesToProcess.Length, Math.Round(((float)prog/ filesToProcess.Length) * 100));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user