From 38c75dc8c5baf675621afdbf942bc5035f90c1f7 Mon Sep 17 00:00:00 2001 From: Mbucari <37587114+Mbucari@users.noreply.github.com> Date: Thu, 12 Jan 2023 09:17:08 -0700 Subject: [PATCH 1/2] Update workflows --- .github/workflows/build.yml | 8 +++++++- .github/workflows/release.yml | 3 ++- .github/workflows/scripts/targz2deb.sh | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47e89f80..37707947 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,12 @@ on: type: boolean description: 'Skip running unit tests' required: false - default: true + default: true + build_deb: + type: boolean + description: 'Build Debian package' + required: false + default: false jobs: windows: @@ -31,6 +36,7 @@ jobs: linux_deb: needs: [linux] + if: inputs.build_deb uses: ./.github/workflows/build-deb.yml with: version: ${{ needs.linux.outputs.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 243606ad..564c8b03 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,7 @@ jobs: with: version_override: ${{ needs.prerelease.outputs.version }} run_unit_tests: false + build_deb: true release: needs: [prerelease,build] @@ -50,7 +51,7 @@ jobs: GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' with: tag_name: '${{ github.ref }}' - release_name: 'Libation ${{ steps.version.outputs.version }}' + release_name: 'Libation ${{ needs.prerelease.outputs.version }}' body: draft: true prerelease: false diff --git a/.github/workflows/scripts/targz2deb.sh b/.github/workflows/scripts/targz2deb.sh index 4143aef8..783eaf47 100644 --- a/.github/workflows/scripts/targz2deb.sh +++ b/.github/workflows/scripts/targz2deb.sh @@ -105,6 +105,9 @@ ln -s /usr/lib/libation/Libation /usr/bin/libation ln -s /usr/lib/libation/Hangover /usr/bin/hangover ln -s /usr/lib/libation/LibationCli /usr/bin/libationcli +# Increase the maximum number of inotify instances +echo fs.inotify.max_user_instances=524288 | tee -a /etc/sysctl.conf && sysctl -p + # workaround until this file is moved to the user's home directory touch /usr/lib/libation/appsettings.json chmod 666 /usr/lib/libation/appsettings.json From 1addcc82117bde8be7574e7814f45b80190b1b8c Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sun, 15 Jan 2023 21:42:03 -0700 Subject: [PATCH 2/2] Update AAXClean and add better error handling --- Source/AaxDecrypter/AaxDecrypter.csproj | 2 +- .../AaxcDownloadMultiConverter.cs | 36 +++++++++++++------ .../AaxcDownloadSingleConverter.cs | 29 ++++++++++----- Source/FileLiberator/ConvertToMp3.cs | 36 ++++++++++++------- 4 files changed, 69 insertions(+), 34 deletions(-) diff --git a/Source/AaxDecrypter/AaxDecrypter.csproj b/Source/AaxDecrypter/AaxDecrypter.csproj index 4236ee60..aea11238 100644 --- a/Source/AaxDecrypter/AaxDecrypter.csproj +++ b/Source/AaxDecrypter/AaxDecrypter.csproj @@ -13,7 +13,7 @@ - + diff --git a/Source/AaxDecrypter/AaxcDownloadMultiConverter.cs b/Source/AaxDecrypter/AaxcDownloadMultiConverter.cs index 4504a50c..d5a03d0e 100644 --- a/Source/AaxDecrypter/AaxcDownloadMultiConverter.cs +++ b/Source/AaxDecrypter/AaxcDownloadMultiConverter.cs @@ -13,6 +13,7 @@ namespace AaxDecrypter { private static TimeSpan minChapterLength { get; } = TimeSpan.FromSeconds(3); private List multiPartFilePaths { get; } = new List(); + private FileStream workingFileStream; public AaxcDownloadMultiConverter(string outFileName, string cacheDirectory, IDownloadOptions dlOptions) : base(outFileName, cacheDirectory, dlOptions) { } @@ -130,18 +131,31 @@ That naming may not be desirable for everyone, but it's an easy change to instea // reset, just in case multiPartFilePaths.Clear(); - ConversionResult result; + try + { + ConversionResult result; - AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; - if (DownloadOptions.OutputFormat == OutputFormat.M4b) - result = await ConvertToMultiMp4a(splitChapters); - else - result = await ConvertToMultiMp3(splitChapters); - AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate; + AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; + if (DownloadOptions.OutputFormat == OutputFormat.M4b) + result = await ConvertToMultiMp4a(splitChapters); + else + result = await ConvertToMultiMp3(splitChapters); - Step_DownloadAudiobook_End(zeroProgress); + return result == ConversionResult.NoErrorsDetected; + } + catch(Exception ex) + { + Serilog.Log.Error(ex, "AAXClean Error"); + workingFileStream?.Close(); + FileUtility.SaferDelete(workingFileStream.Name); + return false; + } + finally + { + AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate; - return result == ConversionResult.NoErrorsDetected; + Step_DownloadAudiobook_End(zeroProgress); + } } private Task ConvertToMultiMp4a(ChapterInfo splitChapters) @@ -195,9 +209,9 @@ That naming may not be desirable for everyone, but it's an easy change to instea FileUtility.SaferDelete(fileName); - var file = File.Open(fileName, FileMode.OpenOrCreate); + workingFileStream = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); OnFileCreated(fileName); - return file; + return workingFileStream; } } } diff --git a/Source/AaxDecrypter/AaxcDownloadSingleConverter.cs b/Source/AaxDecrypter/AaxcDownloadSingleConverter.cs index 04188885..288c06af 100644 --- a/Source/AaxDecrypter/AaxcDownloadSingleConverter.cs +++ b/Source/AaxDecrypter/AaxcDownloadSingleConverter.cs @@ -92,17 +92,28 @@ namespace AaxDecrypter AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate; - ConversionResult decryptionResult = await decryptAsync(outputFile); + try + { + ConversionResult decryptionResult = await decryptAsync(outputFile); + var success = decryptionResult == ConversionResult.NoErrorsDetected && !IsCanceled; + if (success) + base.OnFileCreated(OutputFileName); - AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate; + return success; + } + catch(Exception ex) + { + Serilog.Log.Error(ex, "AAXClean Error"); + FileUtility.SaferDelete(OutputFileName); + return false; + } + finally + { + outputFile.Close(); + AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate; - Step_DownloadAudiobook_End(zeroProgress); - - var success = decryptionResult == ConversionResult.NoErrorsDetected && !IsCanceled; - if (success) - base.OnFileCreated(OutputFileName); - - return success; + Step_DownloadAudiobook_End(zeroProgress); + } } private Task decryptAsync(Stream outputFile) diff --git a/Source/FileLiberator/ConvertToMp3.cs b/Source/FileLiberator/ConvertToMp3.cs index 94744596..5ec07045 100644 --- a/Source/FileLiberator/ConvertToMp3.cs +++ b/Source/FileLiberator/ConvertToMp3.cs @@ -64,30 +64,40 @@ namespace FileLiberator config.LameMatchSourceBR); using var mp3File = File.OpenWrite(Path.GetTempFileName()); - var result = await m4bBook.ConvertToMp3Async(mp3File, lameConfig); - m4bBook.InputStream.Close(); - mp3File.Close(); - - if (result == ConversionResult.Failed) + try { - FileUtility.SaferDelete(mp3File.Name); + var result = await m4bBook.ConvertToMp3Async(mp3File, lameConfig); + + var realMp3Path = FileUtility.SaferMoveToValidPath(mp3File.Name, proposedMp3Path, Configuration.Instance.ReplacementCharacters); + OnFileCreated(libraryBook, realMp3Path); + + if (result == ConversionResult.Failed) + { + FileUtility.SaferDelete(mp3File.Name); + } + else if (result == ConversionResult.Cancelled) + { + FileUtility.SaferDelete(mp3File.Name); + return new StatusHandler { "Cancelled" }; + } + } + catch (Exception ex) + { + Serilog.Log.Error(ex, "AAXClean error"); return new StatusHandler { "Conversion failed" }; } - else if (result == ConversionResult.Cancelled) + finally { - FileUtility.SaferDelete(mp3File.Name); - return new StatusHandler { "Cancelled" }; + m4bBook.InputStream.Close(); + mp3File.Close(); } - - var realMp3Path = FileUtility.SaferMoveToValidPath(mp3File.Name, proposedMp3Path, Configuration.Instance.ReplacementCharacters); - OnFileCreated(libraryBook, realMp3Path); } - return new StatusHandler(); } finally { OnCompleted(libraryBook); } + return new StatusHandler(); } private void M4bBook_ConversionProgressUpdate(object sender, ConversionProgressEventArgs e)