Skip to content

Commit 101187f

Browse files
committed
Error fix in Importing
1 parent 2951003 commit 101187f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

MiniMediaScanner/Commands/ImportCommandHandler.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,24 @@ await AnsiConsole.Progress()
137137
private async Task ChannelThread()
138138
{
139139
List<string> filePaths = new List<string>();
140-
List<string> updatePaths = new List<string>();
141140
while (_importProcessing)
142141
{
143142
await foreach (var path in _processingChannel.Reader.ReadAllAsync())
144143
{
145144
filePaths.Add(path);
146145
if (filePaths.Count == BatchFileProcessing)
147146
{
148-
updatePaths = _forceImport ? filePaths : await _metadataRepository.MetadataCanUpdatePathListAsync(filePaths);
147+
var updatePaths = _forceImport ? filePaths : await _metadataRepository.MetadataCanUpdatePathListAsync(filePaths);
148+
149149
foreach (var file in updatePaths)
150150
{
151+
_progressTask.Value++;
152+
_progressTask.Description = $"Scanning files from '{_scanningDirectoryPath}' {_progressTask.Value}/{_progressTask.MaxValue}";
151153
await ProcessFileAsync(file, _forceImport, _updateMb);
152154
}
155+
156+
_progressTask.Value += filePaths.Count - updatePaths.Count;
157+
_progressTask.Description = $"Scanning files from '{_scanningDirectoryPath}' {_progressTask.Value}/{_progressTask.MaxValue}";
153158

154159
filePaths.Clear();
155160
}
@@ -165,9 +170,11 @@ private async Task ChannelThread()
165170

166171
if (filePaths.Count > 0)
167172
{
168-
updatePaths = _forceImport ? filePaths : await _metadataRepository.MetadataCanUpdatePathListAsync(filePaths);
173+
var updatePaths = _forceImport ? filePaths : await _metadataRepository.MetadataCanUpdatePathListAsync(filePaths);
169174
foreach (var file in updatePaths)
170175
{
176+
_progressTask.Value++;
177+
_progressTask.Description = $"Scanning files from '{_scanningDirectoryPath}' {_progressTask.Value}/{_progressTask.MaxValue}";
171178
await ProcessFileAsync(file, _forceImport, _updateMb);
172179
}
173180
filePaths.Clear();
@@ -176,9 +183,6 @@ private async Task ChannelThread()
176183

177184
public async Task<bool> ProcessFileAsync(string filePath, bool forceReimport = false, bool updateMb = false)
178185
{
179-
_progressTask.Value++;
180-
_progressTask.Description = $"Scanning files from '{_scanningDirectoryPath}' {_progressTask.Value}/{_progressTask.MaxValue}";
181-
182186
var metadata = default(MetadataInfo);
183187

184188
try

0 commit comments

Comments
 (0)