Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Add message for unsupported password-protected 7z archives.
nzbdav-deva75bc6ad5621
diff --git a/backend/Exceptions/PasswordProtected7zException.cs b/backend/Exceptions/PasswordProtected7zException.csnew file mode 100644index 00000000..f2d2ced4--- /dev/null+++ b/backend/Exceptions/PasswordProtected7zException.cs@@ -0,0 +1,5 @@+namespace NzbWebDAV.Exceptions;++public class PasswordProtected7zException(string message) : NonRetryableDownloadException(message)+{+}\ No newline at end of filediff --git a/backend/Utils/SevenZipUtil.cs b/backend/Utils/SevenZipUtil.csindex 3e06adae..cd170d67 100644--- a/backend/Utils/SevenZipUtil.cs+++ b/backend/Utils/SevenZipUtil.cs@@ -1,4 +1,5 @@-using NzbWebDAV.Extensions;+using NzbWebDAV.Exceptions;+using NzbWebDAV.Extensions;using NzbWebDAV.Models;using NzbWebDAV.Streams;using SharpCompress.Archives.SevenZip;@@ -16,11 +17,18 @@ public static class SevenZipUtilpublic static List<SevenZipEntry> GetSevenZipEntries(Stream stream){- using var archive = SevenZipArchive.Open(stream);- return archive.Entries- .Where(x => !x.IsDirectory)- .Select((entry, index) => new SevenZipEntry(entry, archive, index))- .ToList();+ try+ {+ using var archive = SevenZipArchive.Open(stream);+ return archive.Entries+ .Where(x => !x.IsDirectory)+ .Select((entry, index) => new SevenZipEntry(entry, archive, index))+ .ToList();+ }+ catch (CryptographicException e)+ {+ throw new PasswordProtected7zException("Password-protected 7z archives are not supported");+ }}public class SevenZipEntry(SevenZipArchiveEntry entry, SevenZipArchive archive, int index)