Fixed a bug where if a chapter had multiple archive files, they wouldn't all be extracted due to short circuit in ExtractArchive. Now I add the file id then flatten afterwards. (#113)
This commit is contained in:
parent
d2914a0e79
commit
280fdc07f2
2 changed files with 11 additions and 4 deletions
|
@ -41,12 +41,19 @@ namespace API.Services
|
|||
public async Task<Chapter> Ensure(int chapterId)
|
||||
{
|
||||
EnsureCacheDirectory();
|
||||
Chapter chapter = await _unitOfWork.VolumeRepository.GetChapterAsync(chapterId);
|
||||
var chapter = await _unitOfWork.VolumeRepository.GetChapterAsync(chapterId);
|
||||
var fileCount = 0;
|
||||
var extractPath = GetCachePath(chapterId);
|
||||
|
||||
foreach (var file in chapter.Files)
|
||||
{
|
||||
var extractPath = GetCachePath(chapterId);
|
||||
_archiveService.ExtractArchive(file.FilePath, extractPath);
|
||||
_archiveService.ExtractArchive(file.FilePath, Path.Join(extractPath, file.Id + ""));
|
||||
fileCount++;
|
||||
}
|
||||
|
||||
if (fileCount > 1)
|
||||
{
|
||||
new DirectoryInfo(extractPath).Flatten();
|
||||
}
|
||||
|
||||
return chapter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue