Simplify Folder Watcher (#1484)
* Refactored Library Watcher to use Hangfire under the hood. * Support .kavitaignore at root level. * Refactored a lot of the library watching code to process faster and handle when FileSystemWatcher runs out of internal buffer space. It's still not perfect, but good enough for basic use. * Make folder watching as experimental and default it to off by default. * Revert #1479 * Tweaked the messaging for OPDS to remove a note about download role. Moved some code closer to where it's used. * Cleaned up how the events widget reports * Fixed a null issue when deleting series in the UI * Cleaned up some debug code * Added more information for when we skip a scan * Cleaned up some logging messages in CoverGen tasks * More log message tweaks * Added some debug to help identify a rare issue * Fixed a bug where save bookmarks as webp could get reset to false when saving other server settings * Updated some documentation on library watcher. * Make LibraryWatcher fire every 5 mins
This commit is contained in:
parent
b64ed6df8d
commit
b07aaf1eb5
19 changed files with 187 additions and 259 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -68,6 +69,7 @@ public enum ScanCancelReason
|
|||
*/
|
||||
public class ScannerService : IScannerService
|
||||
{
|
||||
public const string Name = "ScannerService";
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ILogger<ScannerService> _logger;
|
||||
private readonly IMetadataService _metadataService;
|
||||
|
|
@ -277,7 +279,7 @@ public class ScannerService : IScannerService
|
|||
return ScanCancelReason.FolderMount;
|
||||
}
|
||||
|
||||
// If all series Folder paths haven't been modified since last scan, abort
|
||||
// If all series Folder paths haven't been modified since last scan, abort (NOTE: This flow never happens as ScanSeries will always bypass)
|
||||
if (!bypassFolderChecks)
|
||||
{
|
||||
|
||||
|
|
@ -293,7 +295,7 @@ public class ScannerService : IScannerService
|
|||
series.Name);
|
||||
await _eventHub.SendMessageAsync(MessageFactory.Info,
|
||||
MessageFactory.InfoEvent($"{series.Name} scan has no work to do",
|
||||
"All folders have not been changed since last scan. Scan will be aborted."));
|
||||
$"All folders have not been changed since last scan ({series.LastFolderScanned.ToString(CultureInfo.CurrentCulture)}). Scan will be aborted."));
|
||||
return ScanCancelReason.NoChange;
|
||||
}
|
||||
}
|
||||
|
|
@ -304,7 +306,7 @@ public class ScannerService : IScannerService
|
|||
series.Name);
|
||||
await _eventHub.SendMessageAsync(MessageFactory.Info,
|
||||
MessageFactory.ErrorEvent($"{series.Name} scan has no work to do",
|
||||
"The folder the series is in is missing. Delete series manually or perform a library scan."));
|
||||
"The folder the series was in is missing. Delete series manually or perform a library scan."));
|
||||
return ScanCancelReason.NoCancel;
|
||||
}
|
||||
}
|
||||
|
|
@ -316,7 +318,7 @@ public class ScannerService : IScannerService
|
|||
private static void RemoveParsedInfosNotForSeries(Dictionary<ParsedSeries, IList<ParserInfo>> parsedSeries, Series series)
|
||||
{
|
||||
var keys = parsedSeries.Keys;
|
||||
foreach (var key in keys.Where(key => !SeriesHelper.FindSeries(series, key))) // series.Format != key.Format ||
|
||||
foreach (var key in keys.Where(key => !SeriesHelper.FindSeries(series, key)))
|
||||
{
|
||||
parsedSeries.Remove(key);
|
||||
}
|
||||
|
|
@ -420,7 +422,7 @@ public class ScannerService : IScannerService
|
|||
_logger.LogInformation("[ScannerService] {LibraryName} scan has no work to do. All folders have not been changed since last scan", library.Name);
|
||||
await _eventHub.SendMessageAsync(MessageFactory.Info,
|
||||
MessageFactory.InfoEvent($"{library.Name} scan has no work to do",
|
||||
"All folders have not been changed since last scan. Scan will be aborted."));
|
||||
$"All folders have not been changed since last scan ({library.Folders.Max(f => f.LastScanned).ToString(CultureInfo.CurrentCulture)}). Scan will be aborted."));
|
||||
|
||||
BackgroundJob.Enqueue(() => _metadataService.GenerateCoversForLibrary(library.Id, false));
|
||||
BackgroundJob.Enqueue(() => _wordCountAnalyzerService.ScanLibrary(library.Id, false));
|
||||
|
|
@ -485,7 +487,7 @@ public class ScannerService : IScannerService
|
|||
|
||||
await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress, MessageFactory.FileScanProgressEvent(string.Empty, library.Name, ProgressEventType.Ended));
|
||||
|
||||
_logger.LogInformation("[ScannerService] Finished file scan in {ScanAndUpdateTime}. Updating database", scanElapsedTime);
|
||||
_logger.LogInformation("[ScannerService] Finished file scan in {ScanAndUpdateTime} milliseconds. Updating database", scanElapsedTime);
|
||||
|
||||
var time = DateTime.Now;
|
||||
foreach (var folderPath in library.Folders)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue