From 0819346192d8928beb0ae76c851b103001dae913 Mon Sep 17 00:00:00 2001
From: dnzbk
Date: Mon, 12 Feb 2024 14:57:19 +0300
Subject: [PATCH 1/6] Refactor: extension unpack error messages
---
daemon/extension/ExtensionManager.cpp | 14 +++++++-------
webui/config.js | 2 +-
webui/index.html | 6 ++++++
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/daemon/extension/ExtensionManager.cpp b/daemon/extension/ExtensionManager.cpp
index 1fe0cad54..0d5c66ac0 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 code = unpacker.Execute();
- if (res != 0)
+ if (code < 0)
{
- if (!FileSystem::DeleteFile(filename.c_str()))
- {
- return "Failed to unpack and delete temp file: " + filename;
- }
+ return "Failed to unpack " + filename + ". Make sure that path to 7-Zip is valid.";
+ }
- return "Failed to unpack " + filename;
+ if (code > 0)
+ {
+ return "Failed to unpack " + filename + ". 7-Zip exit code: " + std::to_string(code);
}
if (!FileSystem::DeleteFile(filename.c_str()))
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..34a6315cd 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -718,6 +718,12 @@
list,
it will be removed without the possibility of reinstalling it.
+
+
+ NOTE:
+ Extension Manager requires 7zip to unpack downloaded extensions.
+ If you are having issues with Extension Manager downloads - please make sure that SevenZipCmd is valid.
+
From 3dd7912b35ebb714ae10ada1f18953272e5b77a6 Mon Sep 17 00:00:00 2001
From: dnzbk
Date: Mon, 12 Feb 2024 16:43:49 +0300
Subject: [PATCH 2/6] Add: 7zip exit codes decoder
---
daemon/extension/ExtensionManager.cpp | 8 ++++----
daemon/postprocess/Unpack.cpp | 29 +++++++++++++++++++++++++++
daemon/postprocess/Unpack.h | 11 ++++++++++
3 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/daemon/extension/ExtensionManager.cpp b/daemon/extension/ExtensionManager.cpp
index 0d5c66ac0..6a574fffb 100644
--- a/daemon/extension/ExtensionManager.cpp
+++ b/daemon/extension/ExtensionManager.cpp
@@ -111,16 +111,16 @@ namespace ExtensionManager
};
unpacker.SetArgs(std::move(args));
- int code = unpacker.Execute();
+ int ec = unpacker.Execute();
- if (code < 0)
+ if (ec < 0)
{
return "Failed to unpack " + filename + ". Make sure that path to 7-Zip is valid.";
}
- if (code > 0)
+ if (ec > 0)
{
- return "Failed to unpack " + filename + ". 7-Zip exit code: " + std::to_string(code);
+ 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..782ed526a 100644
--- a/daemon/postprocess/Unpack.cpp
+++ b/daemon/postprocess/Unpack.cpp
@@ -961,3 +961,32 @@ 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: "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
{
From 2de2c56a8deaa1bdbf86c573c6ae8d97fce4b1b7 Mon Sep 17 00:00:00 2001
From: dnzbk
Date: Mon, 12 Feb 2024 16:46:44 +0300
Subject: [PATCH 3/6] Fix: error message
---
daemon/extension/ExtensionManager.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/extension/ExtensionManager.cpp b/daemon/extension/ExtensionManager.cpp
index 6a574fffb..4f0c088db 100644
--- a/daemon/extension/ExtensionManager.cpp
+++ b/daemon/extension/ExtensionManager.cpp
@@ -115,7 +115,7 @@ namespace ExtensionManager
if (ec < 0)
{
- return "Failed to unpack " + filename + ". Make sure that path to 7-Zip is valid.";
+ return "Failed to unpack " + filename + ". Make sure that the path to 7-Zip is valid.";
}
if (ec > 0)
From d5a88312e8d24beb9b1dca7cb232482b7e89116e Mon Sep 17 00:00:00 2001
From: dnzbk
Date: Mon, 12 Feb 2024 16:52:33 +0300
Subject: [PATCH 4/6] Fix: NOTE text
---
webui/index.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/webui/index.html b/webui/index.html
index 34a6315cd..f6511634c 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -721,8 +721,8 @@
NOTE:
- Extension Manager requires 7zip to unpack downloaded extensions.
- If you are having issues with Extension Manager downloads - please make sure that SevenZipCmd is valid.
+ Extension Manager requires 7-Zip to unpack downloaded extensions.
+ If you are having issues with installing extensions - please make sure that SevenZipCmd is valid.
From 7374ba4d42f219ea09c34375b1cbd01cd9118830 Mon Sep 17 00:00:00 2001
From: dnzbk
Date: Tue, 13 Feb 2024 08:50:41 +0300
Subject: [PATCH 5/6] Fix: return default
---
daemon/postprocess/Unpack.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/daemon/postprocess/Unpack.cpp b/daemon/postprocess/Unpack.cpp
index 782ed526a..48093f3c8 100644
--- a/daemon/postprocess/Unpack.cpp
+++ b/daemon/postprocess/Unpack.cpp
@@ -987,6 +987,7 @@ const char* UnpackController::DecodeSevenZipExitCode(int ec)
case SevenZipExitCodes::CanceledByUser:
return "User stopped the process";
- default: "Unknown 7-Zip error";
+ default:
+ return "Unknown 7-Zip error";
};
}
From 18b69f8f1374a933dc44bdf0b0733ab39f4dfd7e Mon Sep 17 00:00:00 2001
From: dnzbk
Date: Tue, 13 Feb 2024 10:32:34 +0300
Subject: [PATCH 6/6] Add: link to 'SevenZipCmd'
---
webui/index.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/webui/index.html b/webui/index.html
index f6511634c..39b435138 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -722,7 +722,8 @@
NOTE:
Extension Manager requires 7-Zip to unpack downloaded extensions.
- If you are having issues with installing extensions - please make sure that SevenZipCmd is valid.
+ If you are having issues with Extension Manager downloads - please check
+ SevenZipCmd.