Folder Watching (#1467)

* Hooked in a server setting to enable/disable folder watching

* Validated the file rename change event

* Validated delete file works

* Tweaked some logic to determine if a change occurs on a folder or a file.

* Added a note for an upcoming branch

* Some minor changes in the loop that just shift where code runs.

* Implemented ScanFolder api

* Ensure we restart watchers when we modify a library folder.

* Fixed a unit test
This commit is contained in:
Joseph Milazzo 2022-08-23 11:45:11 -05:00 committed by GitHub
parent 87ad5844f0
commit 037a1a5a8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 269 additions and 102 deletions

View file

@ -100,8 +100,6 @@ public class ScannerService : IScannerService
[Queue(TaskScheduler.ScanQueue)]
public async Task ScanFolder(string folder)
{
// NOTE: I might want to move a lot of this code to the LibraryWatcher or something and just pack libraryId and seriesId
// Validate if we are scanning a new series (that belongs to a library) or an existing series
var seriesId = await _unitOfWork.SeriesRepository.GetSeriesIdByFolder(folder);
if (seriesId > 0)
{
@ -109,6 +107,7 @@ public class ScannerService : IScannerService
return;
}
// This is basically rework of what's already done in Library Watcher but is needed if invoked via API
var parentDirectory = _directoryService.GetParentDirectoryName(folder);
if (string.IsNullOrEmpty(parentDirectory)) return; // This should never happen as it's calculated before enqueing
@ -456,6 +455,8 @@ public class ScannerService : IScannerService
Format = parsedFiles.First().Format
};
// NOTE: Could we check if there are multiple found series (different series) and process each one?
if (skippedScan)
{
seenSeries.AddRange(parsedFiles.Select(pf => new ParsedSeries()