Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Rename obfuscated archive files to same as nzb name (#58)

nzbdav-devab1a911d9d1e
diff --git a/backend/Queue/FileAggregators/RarAggregator.cs b/backend/Queue/FileAggregators/RarAggregator.cs
index 188811c2..f657a6e0 100644
--- a/backend/Queue/FileAggregators/RarAggregator.cs
+++ b/backend/Queue/FileAggregators/RarAggregator.cs
@@ -1,6 +1,7 @@
using NzbWebDAV.Database;
using NzbWebDAV.Database.Models;
using NzbWebDAV.Queue.FileProcessors;
+using NzbWebDAV.Utils;
namespace NzbWebDAV.Queue.FileAggregators;
@@ -43,6 +44,15 @@ public class RarAggregator(DavDatabaseClient dbClient, DavItem mountDirectory) :
var parentDirectory = EnsurePath(pathWithinArchive);
var name = Path.GetFileName(pathWithinArchive);
+ // If there is only one file in the archive and the file-name is obfuscated,
+ // then rename the file to the same name as the containing mount directory.
+ if (archiveFiles.Count == 1 && ObfuscationUtil.IsProbablyObfuscated(name))
+ {
+ var extension = Path.GetExtension(name);
+ var mountDirName = Path.GetFileNameWithoutExtension(mountDirectory.Name);
+ name = mountDirName + extension;
+ }
+
var davItem = DavItem.New(
id: Guid.NewGuid(),
parent: parentDirectory,