mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
More cleanup
This commit is contained in:
parent
6ebf5d6254
commit
70cc163cb0
@ -204,8 +204,7 @@ namespace API.Data
|
|||||||
.Include(s => s.Volumes)
|
.Include(s => s.Volumes)
|
||||||
.ThenInclude(v => v.Chapters)
|
.ThenInclude(v => v.Chapters)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
// TODO: refactor this
|
|
||||||
IList<int> chapterIds = new List<int>();
|
IList<int> chapterIds = new List<int>();
|
||||||
foreach (var s in series)
|
foreach (var s in series)
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ namespace API.Interfaces.Services
|
|||||||
{
|
{
|
||||||
void ExtractArchive(string archivePath, string extractPath);
|
void ExtractArchive(string archivePath, string extractPath);
|
||||||
int GetNumberOfPagesFromArchive(string archivePath);
|
int GetNumberOfPagesFromArchive(string archivePath);
|
||||||
byte[] GetCoverImage(string filepath, bool createThumbnail = false);
|
byte[] GetCoverImage(string archivePath, bool createThumbnail = false);
|
||||||
bool IsValidArchive(string archivePath);
|
bool IsValidArchive(string archivePath);
|
||||||
string GetSummaryInfo(string archivePath);
|
string GetSummaryInfo(string archivePath);
|
||||||
ArchiveLibrary CanOpen(string archivePath);
|
ArchiveLibrary CanOpen(string archivePath);
|
||||||
|
@ -42,7 +42,6 @@ namespace API.Services
|
|||||||
{
|
{
|
||||||
using var a2 = ZipFile.OpenRead(archivePath);
|
using var a2 = ZipFile.OpenRead(archivePath);
|
||||||
return ArchiveLibrary.Default;
|
return ArchiveLibrary.Default;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -65,10 +64,7 @@ namespace API.Services
|
|||||||
_logger.LogError("Archive {ArchivePath} could not be found", archivePath);
|
_logger.LogError("Archive {ArchivePath} could not be found", archivePath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
var count = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var libraryHandler = CanOpen(archivePath);
|
var libraryHandler = CanOpen(archivePath);
|
||||||
@ -316,14 +312,12 @@ namespace API.Services
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ArchiveLibrary.NotSupported:
|
case ArchiveLibrary.NotSupported:
|
||||||
_logger.LogError("[GetNumberOfPagesFromArchive] This archive cannot be read: {ArchivePath}. Defaulting to 0 pages", archivePath);
|
_logger.LogError("[GetSummaryInfo] This archive cannot be read: {ArchivePath}. Defaulting to 0 pages", archivePath);
|
||||||
return summary;
|
return summary;
|
||||||
default:
|
default:
|
||||||
_logger.LogError("[GetNumberOfPagesFromArchive] There was an exception when reading archive stream: {ArchivePath}. Defaulting to 0 pages", archivePath);
|
_logger.LogError("[GetSummaryInfo] There was an exception when reading archive stream: {ArchivePath}. Defaulting to 0 pages", archivePath);
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (info != null)
|
if (info != null)
|
||||||
{
|
{
|
||||||
@ -340,7 +334,7 @@ namespace API.Services
|
|||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExtractArchiveEntities(IEnumerable<IArchiveEntry> entries, string extractPath)
|
private static void ExtractArchiveEntities(IEnumerable<IArchiveEntry> entries, string extractPath)
|
||||||
{
|
{
|
||||||
DirectoryService.ExistOrCreate(extractPath);
|
DirectoryService.ExistOrCreate(extractPath);
|
||||||
foreach (var entry in entries)
|
foreach (var entry in entries)
|
||||||
@ -390,7 +384,7 @@ namespace API.Services
|
|||||||
case ArchiveLibrary.Default:
|
case ArchiveLibrary.Default:
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Using default compression handling");
|
_logger.LogDebug("Using default compression handling");
|
||||||
using ZipArchive archive = ZipFile.OpenRead(archivePath);
|
using var archive = ZipFile.OpenRead(archivePath);
|
||||||
ExtractArchiveEntries(archive, extractPath);
|
ExtractArchiveEntries(archive, extractPath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -418,5 +412,4 @@ namespace API.Services
|
|||||||
_logger.LogDebug("Extracted archive to {ExtractPath} in {ElapsedMilliseconds} milliseconds", extractPath, sw.ElapsedMilliseconds);
|
_logger.LogDebug("Extracted archive to {ExtractPath} in {ElapsedMilliseconds} milliseconds", extractPath, sw.ElapsedMilliseconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user