Code cleanup. Implemented ability to schedule Library Backups.
This commit is contained in:
parent
83b9394b17
commit
b4ee16d8d1
35 changed files with 217 additions and 91 deletions
13
API/Interfaces/Services/IArchiveService.cs
Normal file
13
API/Interfaces/Services/IArchiveService.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.IO.Compression;
|
||||
|
||||
namespace API.Interfaces.Services
|
||||
{
|
||||
public interface IArchiveService
|
||||
{
|
||||
bool ArchiveNeedsFlattening(ZipArchive archive);
|
||||
void ExtractArchive(string archivePath, string extractPath);
|
||||
int GetNumberOfPagesFromArchive(string archivePath);
|
||||
byte[] GetCoverImage(string filepath, bool createThumbnail = false);
|
||||
bool IsValidArchive(string archivePath);
|
||||
}
|
||||
}
|
7
API/Interfaces/Services/IBackupService.cs
Normal file
7
API/Interfaces/Services/IBackupService.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace API.Interfaces.Services
|
||||
{
|
||||
public interface IBackupService
|
||||
{
|
||||
void BackupDatabase();
|
||||
}
|
||||
}
|
38
API/Interfaces/Services/ICacheService.cs
Normal file
38
API/Interfaces/Services/ICacheService.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System.Threading.Tasks;
|
||||
using API.Entities;
|
||||
|
||||
namespace API.Interfaces.Services
|
||||
{
|
||||
public interface ICacheService
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensures the cache is created for the given chapter and if not, will create it. Should be called before any other
|
||||
/// cache operations (except cleanup).
|
||||
/// </summary>
|
||||
/// <param name="chapterId"></param>
|
||||
/// <returns>Chapter for the passed chapterId. Side-effect from ensuring cache.</returns>
|
||||
Task<Chapter> Ensure(int chapterId);
|
||||
|
||||
/// <summary>
|
||||
/// Clears cache directory of all folders and files.
|
||||
/// </summary>
|
||||
void Cleanup();
|
||||
|
||||
/// <summary>
|
||||
/// Clears cache directory of all volumes. This can be invoked from deleting a library or a series.
|
||||
/// </summary>
|
||||
/// <param name="chapterIds">Volumes that belong to that library. Assume the library might have been deleted before this invocation.</param>
|
||||
void CleanupChapters(int[] chapterIds);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the absolute path of a cached page.
|
||||
/// </summary>
|
||||
/// <param name="chapter">Chapter entity with Files populated.</param>
|
||||
/// <param name="page">Page number to look for</param>
|
||||
/// <returns></returns>
|
||||
Task<(string path, MangaFile file)> GetCachedPagePath(Chapter chapter, int page);
|
||||
|
||||
void EnsureCacheDirectory();
|
||||
}
|
||||
}
|
31
API/Interfaces/Services/IDirectoryService.cs
Normal file
31
API/Interfaces/Services/IDirectoryService.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using API.DTOs;
|
||||
|
||||
namespace API.Interfaces.Services
|
||||
{
|
||||
public interface IDirectoryService
|
||||
{
|
||||
/// <summary>
|
||||
/// Lists out top-level folders for a given directory. Filters out System and Hidden folders.
|
||||
/// </summary>
|
||||
/// <param name="rootPath">Absolute path of directory to scan.</param>
|
||||
/// <returns>List of folder names</returns>
|
||||
IEnumerable<string> ListDirectory(string rootPath);
|
||||
|
||||
Task<ImageDto> ReadImageAsync(string imagePath);
|
||||
/// <summary>
|
||||
/// Gets files in a directory. If searchPatternExpression is passed, will match the regex against for filtering.
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="searchPatternExpression"></param>
|
||||
/// <returns></returns>
|
||||
string[] GetFiles(string path, string searchPatternExpression = "");
|
||||
/// <summary>
|
||||
/// Returns true if the path exists and is a directory. If path does not exist, this will create it. Returns false in all fail cases.
|
||||
/// </summary>
|
||||
/// <param name="directoryPath"></param>
|
||||
/// <returns></returns>
|
||||
bool ExistOrCreate(string directoryPath);
|
||||
}
|
||||
}
|
15
API/Interfaces/Services/IScannerService.cs
Normal file
15
API/Interfaces/Services/IScannerService.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
namespace API.Interfaces.Services
|
||||
{
|
||||
public interface IScannerService
|
||||
{
|
||||
/// <summary>
|
||||
/// Given a library id, scans folders for said library. Parses files and generates DB updates. Will overwrite
|
||||
/// cover images if forceUpdate is true.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Library to scan against</param>
|
||||
/// <param name="forceUpdate">Force overwriting for cover images</param>
|
||||
void ScanLibrary(int libraryId, bool forceUpdate);
|
||||
|
||||
void ScanLibraries();
|
||||
}
|
||||
}
|
10
API/Interfaces/Services/ITokenService.cs
Normal file
10
API/Interfaces/Services/ITokenService.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using System.Threading.Tasks;
|
||||
using API.Entities;
|
||||
|
||||
namespace API.Interfaces.Services
|
||||
{
|
||||
public interface ITokenService
|
||||
{
|
||||
Task<string> CreateToken(AppUser user);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue