diff --git a/daemon/extension/ExtensionManager.cpp b/daemon/extension/ExtensionManager.cpp index 1fe0cad54..4f0c088db 100644 --- a/daemon/extension/ExtensionManager.cpp +++ b/daemon/extension/ExtensionManager.cpp @@ -111,16 +111,16 @@ namespace ExtensionManager }; unpacker.SetArgs(std::move(args)); - int res = unpacker.Execute(); + int ec = unpacker.Execute(); - if (res != 0) + if (ec < 0) { - if (!FileSystem::DeleteFile(filename.c_str())) - { - return "Failed to unpack and delete temp file: " + filename; - } + return "Failed to unpack " + filename + ". Make sure that the path to 7-Zip is valid."; + } - return "Failed to unpack " + filename; + if (ec > 0) + { + return "Failed to unpack " + filename + ". " + UnpackController::DecodeSevenZipExitCode(ec); } if (!FileSystem::DeleteFile(filename.c_str())) diff --git a/daemon/postprocess/Unpack.cpp b/daemon/postprocess/Unpack.cpp index b37065a4c..48093f3c8 100644 --- a/daemon/postprocess/Unpack.cpp +++ b/daemon/postprocess/Unpack.cpp @@ -961,3 +961,33 @@ bool UnpackController::HasCompletedArchiveFiles(NzbInfo* nzbInfo) return false; } + +const char* UnpackController::DecodeSevenZipExitCode(int ec) +{ + // 7-Zip exit codes according to https://documentation.help/7-Zip/exit_codes.htm + switch (ec) + { + case SevenZipExitCodes::NoError: + return "No error"; + + case SevenZipExitCodes::Warning: + return "Warning (Non fatal error(s)). \ + For example, one or more files were locked by some other application, \ + so they were not compressed."; + + case SevenZipExitCodes::FatalError: + return "Fatal error"; + + case SevenZipExitCodes::CmdLineError: + return "Command line error"; + + case SevenZipExitCodes::NotEnoughMemoryError: + return "Not enough memory for operation"; + + case SevenZipExitCodes::CanceledByUser: + return "User stopped the process"; + + default: + return "Unknown 7-Zip error"; + }; +} diff --git a/daemon/postprocess/Unpack.h b/daemon/postprocess/Unpack.h index c44c903a7..560ddb927 100644 --- a/daemon/postprocess/Unpack.h +++ b/daemon/postprocess/Unpack.h @@ -33,6 +33,7 @@ class UnpackController : public Thread, public ScriptController virtual void Stop(); static void StartJob(PostInfo* postInfo); static bool HasCompletedArchiveFiles(NzbInfo* nzbInfo); + static const char* DecodeSevenZipExitCode(int ec); protected: virtual bool ReadLine(char* buf, int bufSize, FILE* stream); @@ -45,6 +46,16 @@ class UnpackController : public Thread, public ScriptController upSevenZip }; + enum SevenZipExitCodes + { + NoError = 0, + Warning = 1, + FatalError = 2, + CmdLineError = 7, + NotEnoughMemoryError = 8, + CanceledByUser = 255, + }; + typedef std::vector FileListBase; class FileList : public FileListBase { diff --git a/webui/config.js b/webui/config.js index 5521c57fd..b83ad44ef 100644 --- a/webui/config.js +++ b/webui/config.js @@ -3354,7 +3354,7 @@ var ExtensionManager = (new function($) { hideLoadingBanner(); render(getAllExtensions()); - showErrorBanner("Failed to download extensions", error); + showErrorBanner("Failed to fetch the list of available extensions", error); } ); } diff --git a/webui/index.html b/webui/index.html index dc1925f9d..39b435138 100644 --- a/webui/index.html +++ b/webui/index.html @@ -718,6 +718,13 @@

list, it will be removed without the possibility of reinstalling it. +
+
+ NOTE: + Extension Manager requires 7-Zip to unpack downloaded extensions. + If you are having issues with Extension Manager downloads - please check + SevenZipCmd. +