Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/extension unpacking error messages #166

Merged
merged 6 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions daemon/extension/ExtensionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
30 changes: 30 additions & 0 deletions daemon/postprocess/Unpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
}
11 changes: 11 additions & 0 deletions daemon/postprocess/Unpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<CString> FileListBase;
class FileList : public FileListBase
{
Expand Down
2 changes: 1 addition & 1 deletion webui/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
);
}
Expand Down
7 changes: 7 additions & 0 deletions webui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,13 @@ <h4 class="alert-heading" id="ExtensionsErrorAlert-title"></h4>
<a href="https://github.com/nzbgetcom/nzbget-extensions/blob/main/extensions.json" target="_blank"> list</a>,
it will be removed without the possibility of reinstalling it.
</span>
<br>
<br>
<span class="label label-warning">NOTE:</span>
<span class="help-option-title">Extension Manager requires 7-Zip to unpack downloaded extensions.
If you are having issues with Extension Manager downloads - please check
<a href="#" onclick="Config.scrollToOption(event, this)">SevenZipCmd</a>.
</span>
</p>

<br>
Expand Down