From 541489d0d3770aad7d3e2069d0af5d41f5f2057a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 23 Apr 2026 15:43:25 +0000 Subject: [PATCH] fix: sanitize RdName in TorBox MoveHashDirContents UnpackClient now sanitizes the torrent directory name when building extractPath, so the post-unpack TorBox move needs to compare against the sanitized name as well. Without this, extractPath.EndsWith(rdName) takes the wrong branch for any torrent whose RdName contained brackets and files end up in the hash subdirectory instead of the torrent directory. Reported by @omgbeez. --- .../Services/DebridClients/TorBoxDebridClient.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/RdtClient.Service/Services/DebridClients/TorBoxDebridClient.cs b/server/RdtClient.Service/Services/DebridClients/TorBoxDebridClient.cs index 7a096a2..42ae903 100644 --- a/server/RdtClient.Service/Services/DebridClients/TorBoxDebridClient.cs +++ b/server/RdtClient.Service/Services/DebridClients/TorBoxDebridClient.cs @@ -610,9 +610,13 @@ public class TorBoxDebridClient(ILogger logger, IHttpClientF { var innerFolder = Directory.GetDirectories(hashDir)[0]; + // extractPath may have been sanitized by FilenameSanitizer when the torrent + // directory was created, so compare against the sanitized RdName too. + var rdName = FilenameSanitizer.SanitizeFilenameIfEnabled(torrent.RdName!); + var moveDir = extractPath; - if (!extractPath.EndsWith(torrent.RdName!)) + if (!extractPath.EndsWith(rdName)) { moveDir = hashDir; } @@ -629,7 +633,7 @@ public class TorBoxDebridClient(ILogger logger, IHttpClientF Directory.Move(dir, destDir); } - if (!extractPath.Contains(torrent.RdName!)) + if (!extractPath.Contains(rdName)) { Directory.Delete(innerFolder, true); }