Release Testing Day 1 (#1491)
* Fixed a bug where typeahead wouldn't automatically show results on relationship screen without an additional click. * Tweaked the code which checks if a modification occured to check on seconds rather than minutes * Clear cache will now clear temp/ directory as well. * Fixed an issue where Chrome was caching api responses when it shouldn't had. * Added a cleanup temp code * Ensure genres get removed during series scan when removed from metadata. * Fixed a bug where all epubs with a volume would show as Volume 0 in reading list * When a scan is in progress, don't let the user delete the library.
This commit is contained in:
parent
fb86ce4542
commit
d7f2661655
14 changed files with 112 additions and 32 deletions
|
|
@ -44,6 +44,7 @@ public interface IMetadataService
|
|||
|
||||
public class MetadataService : IMetadataService
|
||||
{
|
||||
public const string Name = "MetadataService";
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ILogger<MetadataService> _logger;
|
||||
private readonly IEventHub _eventHub;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ public class TaskScheduler : ITaskScheduler
|
|||
public const string ScanQueue = "scan";
|
||||
public const string DefaultQueue = "default";
|
||||
|
||||
public static readonly IList<string> ScanTasks = new List<string>()
|
||||
{"ScannerService", "ScanLibrary", "ScanLibraries", "ScanFolder", "ScanSeries"};
|
||||
|
||||
private static readonly Random Rnd = new Random();
|
||||
|
||||
|
||||
|
|
@ -172,7 +175,7 @@ public class TaskScheduler : ITaskScheduler
|
|||
|
||||
public void ScanLibraries()
|
||||
{
|
||||
if (RunningAnyTasksByMethod(new List<string>() {"ScannerService", "ScanLibrary", "ScanLibraries", "ScanFolder", "ScanSeries"}, ScanQueue))
|
||||
if (RunningAnyTasksByMethod(ScanTasks, ScanQueue))
|
||||
{
|
||||
_logger.LogInformation("A Scan is already running, rescheduling ScanLibraries in 3 hours");
|
||||
BackgroundJob.Schedule(() => ScanLibraries(), TimeSpan.FromHours(3));
|
||||
|
|
@ -191,7 +194,7 @@ public class TaskScheduler : ITaskScheduler
|
|||
_logger.LogInformation("A duplicate request to scan library for library occured. Skipping");
|
||||
return;
|
||||
}
|
||||
if (RunningAnyTasksByMethod(new List<string>() {"ScannerService", "ScanLibrary", "ScanLibraries", "ScanFolder", "ScanSeries"}, ScanQueue))
|
||||
if (RunningAnyTasksByMethod(ScanTasks, ScanQueue))
|
||||
{
|
||||
_logger.LogInformation("A Scan is already running, rescheduling ScanLibrary in 3 hours");
|
||||
BackgroundJob.Schedule(() => ScanLibrary(libraryId, force), TimeSpan.FromHours(3));
|
||||
|
|
@ -211,7 +214,7 @@ public class TaskScheduler : ITaskScheduler
|
|||
|
||||
public void RefreshMetadata(int libraryId, bool forceUpdate = true)
|
||||
{
|
||||
var alreadyEnqueued = HasAlreadyEnqueuedTask("MetadataService", "GenerateCoversForLibrary",
|
||||
var alreadyEnqueued = HasAlreadyEnqueuedTask(MetadataService.Name, "GenerateCoversForLibrary",
|
||||
new object[] {libraryId, true}) ||
|
||||
HasAlreadyEnqueuedTask("MetadataService", "GenerateCoversForLibrary",
|
||||
new object[] {libraryId, false});
|
||||
|
|
@ -227,7 +230,7 @@ public class TaskScheduler : ITaskScheduler
|
|||
|
||||
public void RefreshSeriesMetadata(int libraryId, int seriesId, bool forceUpdate = false)
|
||||
{
|
||||
if (HasAlreadyEnqueuedTask("MetadataService","GenerateCoversForSeries", new object[] {libraryId, seriesId, forceUpdate}))
|
||||
if (HasAlreadyEnqueuedTask(MetadataService.Name,"GenerateCoversForSeries", new object[] {libraryId, seriesId, forceUpdate}))
|
||||
{
|
||||
_logger.LogInformation("A duplicate request to refresh metadata for library occured. Skipping");
|
||||
return;
|
||||
|
|
@ -244,7 +247,7 @@ public class TaskScheduler : ITaskScheduler
|
|||
_logger.LogInformation("A duplicate request to scan series occured. Skipping");
|
||||
return;
|
||||
}
|
||||
if (RunningAnyTasksByMethod(new List<string>() {ScannerService.Name, "ScanLibrary", "ScanLibraries", "ScanFolder", "ScanSeries"}, ScanQueue))
|
||||
if (RunningAnyTasksByMethod(ScanTasks, ScanQueue))
|
||||
{
|
||||
_logger.LogInformation("A Scan is already running, rescheduling ScanSeries in 10 minutes");
|
||||
BackgroundJob.Schedule(() => ScanSeries(libraryId, seriesId, forceUpdate), TimeSpan.FromMinutes(10));
|
||||
|
|
@ -282,6 +285,13 @@ public class TaskScheduler : ITaskScheduler
|
|||
await _versionUpdaterService.PushUpdate(update);
|
||||
}
|
||||
|
||||
public static bool HasScanTaskRunningForLibrary(int libraryId)
|
||||
{
|
||||
return
|
||||
HasAlreadyEnqueuedTask("ScannerService", "ScanLibrary", new object[] {libraryId, true}, ScanQueue) ||
|
||||
HasAlreadyEnqueuedTask("ScannerService", "ScanLibrary", new object[] {libraryId, false}, ScanQueue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if this same invocation is already enqueued
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ namespace API.Services.Tasks
|
|||
Task DeleteChapterCoverImages();
|
||||
Task DeleteTagCoverImages();
|
||||
Task CleanupBackups();
|
||||
void CleanupTemp();
|
||||
}
|
||||
/// <summary>
|
||||
/// Cleans up after operations on reoccurring basis
|
||||
|
|
@ -127,16 +128,18 @@ namespace API.Services.Tasks
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all files and directories in the cache directory
|
||||
/// Removes all files and directories in the cache and temp directory
|
||||
/// </summary>
|
||||
public void CleanupCacheDirectory()
|
||||
{
|
||||
_logger.LogInformation("Performing cleanup of Cache directory");
|
||||
_directoryService.ExistOrCreate(_directoryService.CacheDirectory);
|
||||
_directoryService.ExistOrCreate(_directoryService.TempDirectory);
|
||||
|
||||
try
|
||||
{
|
||||
_directoryService.ClearDirectory(_directoryService.CacheDirectory);
|
||||
_directoryService.ClearDirectory(_directoryService.TempDirectory);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -175,5 +178,22 @@ namespace API.Services.Tasks
|
|||
}
|
||||
_logger.LogInformation("Finished cleanup of Database backups at {Time}", DateTime.Now);
|
||||
}
|
||||
|
||||
public void CleanupTemp()
|
||||
{
|
||||
_logger.LogInformation("Performing cleanup of Temp directory");
|
||||
_directoryService.ExistOrCreate(_directoryService.TempDirectory);
|
||||
|
||||
try
|
||||
{
|
||||
_directoryService.ClearDirectory(_directoryService.TempDirectory);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "There was an issue deleting one or more folders/files during cleanup");
|
||||
}
|
||||
|
||||
_logger.LogInformation("Temp directory purged");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,12 +289,19 @@ namespace API.Services.Tasks.Scanner
|
|||
await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress, MessageFactory.FileScanProgressEvent("File Scan Done", libraryName, ProgressEventType.Ended));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks against all folder paths on file if the last scanned is >= the directory's last write down to the second
|
||||
/// </summary>
|
||||
/// <param name="seriesPaths"></param>
|
||||
/// <param name="normalizedFolder"></param>
|
||||
/// <param name="forceCheck"></param>
|
||||
/// <returns></returns>
|
||||
private bool HasSeriesFolderNotChangedSinceLastScan(IDictionary<string, IList<SeriesModified>> seriesPaths, string normalizedFolder, bool forceCheck = false)
|
||||
{
|
||||
if (forceCheck) return false;
|
||||
|
||||
return seriesPaths.ContainsKey(normalizedFolder) && seriesPaths[normalizedFolder].All(f => f.LastScanned.Truncate(TimeSpan.TicksPerMinute) >=
|
||||
_directoryService.GetLastWriteTime(normalizedFolder).Truncate(TimeSpan.TicksPerMinute));
|
||||
return seriesPaths.ContainsKey(normalizedFolder) && seriesPaths[normalizedFolder].All(f => f.LastScanned.Truncate(TimeSpan.TicksPerSecond) >=
|
||||
_directoryService.GetLastWriteTime(normalizedFolder).Truncate(TimeSpan.TicksPerSecond));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -375,6 +375,13 @@ public class ProcessSeries : IProcessSeries
|
|||
}
|
||||
}
|
||||
|
||||
var genres = chapters.SelectMany(c => c.Genres).ToList();
|
||||
GenreHelper.KeepOnlySameGenreBetweenLists(series.Metadata.Genres.ToList(), genres, genre =>
|
||||
{
|
||||
if (series.Metadata.GenresLocked) return;
|
||||
series.Metadata.Genres.Remove(genre);
|
||||
});
|
||||
|
||||
// NOTE: The issue here is that people is just from chapter, but series metadata might already have some people on it
|
||||
// I might be able to filter out people that are in locked fields?
|
||||
var people = chapters.SelectMany(c => c.People).ToList();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue