Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Added support for par2 filenames containing relative paths.
nzbdav-dev686878b95cbe
diff --git a/backend/Queue/FileAggregators/BaseAggregator.cs b/backend/Queue/FileAggregators/BaseAggregator.csindex ef586e03..a4d62859 100644--- a/backend/Queue/FileAggregators/BaseAggregator.cs+++ b/backend/Queue/FileAggregators/BaseAggregator.cs@@ -10,10 +10,21 @@ public abstract class BaseAggregatorprotected abstract DavDatabaseClient DBClient { get; }protected abstract DavItem MountDirectory { get; }- protected DavItem EnsureExtractPath(string pathWithinArchive)+ private static readonly char[] DirectorySeparators =+ [+ Path.DirectorySeparatorChar,+ Path.AltDirectorySeparatorChar+ ];++ /// <summary>+ /// Ensures that all parent-directories for the given `relativePath` exist.+ /// </summary>+ /// <param name="relativePath">The path at which to place a file, relative to the `MountDirectory`.</param>+ /// <returns>The parentDirectory DavItem</returns>+ protected DavItem EnsureParentDirectory(string relativePath){- var pathSegments = pathWithinArchive- .Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)+ var pathSegments = relativePath+ .Split(DirectorySeparators, StringSplitOptions.RemoveEmptyEntries).ToArray();var parentDirectory = MountDirectory;var pathKey = "";diff --git a/backend/Queue/FileAggregators/FileAggregator.cs b/backend/Queue/FileAggregators/FileAggregator.csindex 0f46cb43..1b19f95d 100644--- a/backend/Queue/FileAggregators/FileAggregator.cs+++ b/backend/Queue/FileAggregators/FileAggregator.cs@@ -16,11 +16,13 @@ public class FileAggregator(DavDatabaseClient dbClient, DavItem mountDirectory,{if (processorResult is not FileProcessor.Result result) continue;if (result.FileName == "") continue; // skip files whose name we can't determine+ var parentDirectory = EnsureParentDirectory(result.FileName);+ var name = Path.GetFileName(result.FileName);var davItem = DavItem.New(id: Guid.NewGuid(),- parent: mountDirectory,- name: result.FileName,+ parent: parentDirectory,+ name: name,fileSize: result.FileSize,type: DavItem.ItemType.NzbFile,releaseDate: result.ReleaseDate,diff --git a/backend/Queue/FileAggregators/RarAggregator.cs b/backend/Queue/FileAggregators/RarAggregator.csindex 90e77d36..59e8b43b 100644--- a/backend/Queue/FileAggregators/RarAggregator.cs+++ b/backend/Queue/FileAggregators/RarAggregator.cs@@ -40,7 +40,7 @@ public class RarAggregator(DavDatabaseClient dbClient, DavItem mountDirectory, bvar fileParts = SortByPartNumber(archiveFile.Value);var aesParams = fileParts.Select(x => x.AesParams).FirstOrDefault(x => x != null);var fileSize = aesParams?.DecodedSize ?? fileParts.Sum(x => x.ByteRangeWithinPart.Count);- var parentDirectory = EnsureExtractPath(pathWithinArchive);+ var parentDirectory = EnsureParentDirectory(pathWithinArchive);var name = Path.GetFileName(pathWithinArchive);// If there is only one file in the archive and the file-name is obfuscated,diff --git a/backend/Queue/FileAggregators/SevenZipAggregator.cs b/backend/Queue/FileAggregators/SevenZipAggregator.csindex 38623a78..0bd24755 100644--- a/backend/Queue/FileAggregators/SevenZipAggregator.cs+++ b/backend/Queue/FileAggregators/SevenZipAggregator.cs@@ -30,7 +30,7 @@ public class SevenZipAggregator({var pathWithinArchive = sevenZipFile.PathWithinArchive;var davMultipartFileMeta = sevenZipFile.DavMultipartFileMeta;- var parentDirectory = EnsureExtractPath(pathWithinArchive);+ var parentDirectory = EnsureParentDirectory(pathWithinArchive);var name = Path.GetFileName(pathWithinArchive);// If there is only one file in the archive and the file-name is obfuscated,