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:
Joseph Milazzo 2021-03-26 13:43:54 -05:00 committed by GitHub
parent d2914a0e79
commit 280fdc07f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -41,12 +41,19 @@ namespace API.Services
public async Task<Chapter> Ensure(int chapterId) public async Task<Chapter> Ensure(int chapterId)
{ {
EnsureCacheDirectory(); 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) foreach (var file in chapter.Files)
{ {
var extractPath = GetCachePath(chapterId); _archiveService.ExtractArchive(file.FilePath, Path.Join(extractPath, file.Id + ""));
_archiveService.ExtractArchive(file.FilePath, extractPath); fileCount++;
}
if (fileCount > 1)
{
new DirectoryInfo(extractPath).Flatten();
} }
return chapter; return chapter;

View File

@ -62,7 +62,7 @@ Package()
ProgressStart "Creating $runtime Package for $framework" ProgressStart "Creating $runtime Package for $framework"
# TODO: Use no-restore? Because Build should have already done it for us
echo "Building" echo "Building"
cd API cd API
echo dotnet publish -c release --self-contained --runtime $runtime -o "$lOutputFolder" --framework $framework echo dotnet publish -c release --self-contained --runtime $runtime -o "$lOutputFolder" --framework $framework