Commit graph

35 commits

Author SHA1 Message Date
Claude
582bbd7a78
fix: address review feedback on filename sanitizer
- Revert GetFileName to return unsanitized name. AllDebridDebridClient.
  GetSymlinkPath matches torrent.Files[].Path (original debrid data)
  against GetFileName, so sanitizing it broke AllDebrid Symlink lookups
  for any torrent with bracketed filenames. Sanitization now happens
  inside GetDownloadPath at the point the filesystem path is assembled,
  while matching still uses the unsanitized name.

- Make SanitizeFilename / SanitizePath accept String? and return
  String.Empty for null/empty input so the declared non-null return
  type is honoured.

- SanitizePath splits on both '/' and '\\' regardless of host OS, so
  paths arriving from the debrid provider with foreign separators are
  still segmented correctly on Linux containers.

- Rewrite the control-character tests to use explicit \u escape
  sequences (, , , €, Ÿ) so the test
  inputs are visible in diffs and survive editor/CI round-trips.
  Replace the single-row empty [Theory] with a [Fact] and add a null
  case. Add tests asserting SanitizeFilenameIfEnabled and
  SanitizePathIfEnabled return input unchanged when the toggle is
  disabled, and sanitize when enabled.
2026-04-23 06:55:34 +00:00
Claude
1098bac18f
feat: strip problematic characters from downloaded filenames
Downloads fail on Linux containers when filenames contain square
brackets or multiple consecutive spaces. On Linux, .NET's
Path.GetInvalidFileNameChars() only returns NUL and '/', so characters
like [ ] { } that cause issues with shell globbing, URI handling, and
various download clients pass through the existing filter unchanged.

Add FilenameSanitizer that:
- Strips square brackets, curly braces, and control characters
- Collapses multiple consecutive spaces into one
- Trims leading and trailing whitespace
- Preserves parentheses and all other characters

Apply sanitization at filesystem boundaries: DownloadHelper (where the
Real-Debrid filename is turned into a local path), UnpackClient,
Torrent delete / RunOnTorrentComplete, and the qBittorrent / SABnzbd
status paths that *arr reads back. Aria2c and DownloadStation also
sanitize their remote output paths so they match the sanitized local
filePath. Symlink's rclone-mount lookup still uses the original name
since that has to match the real file in the mount.

Add a SanitizeFilenames toggle in DbSettings (default on) so users
can disable the behaviour if they need the exact Real-Debrid name.
2026-04-23 06:19:25 +00:00
Alexandre Vassard
6743bd472e fix(symlink): normalize subpath first component before comparing torrent name prefix
The previous fix compared subPath directly against the sanitized torrent
name, which fails when RdName contains characters removed by
RemoveInvalidPathChars (e.g. ':' on Windows). Extract and normalize the
first component of subPath before comparing so both sides go through the
same sanitization. Add tests covering the duplicate-prefix stripping case.
2026-03-08 21:29:33 +01:00
Alexandre Vassard
1dd7ab9c8e fix(symlink): strip duplicate torrent name from subpath
torrent.Files[].Path already includes the torrent name as its first
component (e.g. "Hijack/Saison 1/file.mkv"), but GetDownloadPath was
also initialising torrentPath with torrent.RdName, causing the name
to appear twice (e.g. "Hijack/Hijack/Saison 1"). Strip the torrent
name prefix from subPath before combining so the resolved path matches
the actual rclone mount layout.
2026-03-08 21:15:34 +01:00
Roger Far
a9648248f4 Global formatting. 2026-02-11 19:44:49 -07:00
Cucumberrbob
daf8a9c6da
DownloadHelper: use IFileSystem for testable filesystem access 2025-02-17 21:57:02 +00:00
Roger Far
ef8142453f
Merge branch 'master' into fix/bad-download-path 2025-01-29 18:59:31 -07:00
Cucumberrbob
82f0bb8bbe
Use static GetSymlinkPath on AllDebridTorrentClient to get the symlink (since the behaviour is unique to the debrid service) 2025-01-29 12:11:25 +00:00
Cucumberrbob
beb0299a0b
revert changes to DownloadHelper.cs 2025-01-29 11:07:20 +00:00
YvesPa
eeef6fb7fe Merge remote-tracking branch 'rogerfar/master'
# Conflicts:
#	server/RdtClient.Service/RdtClient.Service.csproj
#	server/RdtClient.Service/Services/DownloadClient.cs
2025-01-22 19:11:23 +01:00
YvesPa
7d2d7fa35f Merge remote-tracking branch 'rogerfar/master' 2025-01-10 16:27:04 +01:00
Sculas
ee9e80f7d2
fix: Only apply AllDebrid-specific path fixes to AllDebrid 2025-01-06 12:41:41 +01:00
Roger Far
d5ee5d209c Changed how files are saved. 2025-01-05 20:56:37 -07:00
Sculas
268bb6826c
fix: Fix invalid download path with single-file torrents 2025-01-05 22:17:22 +01:00
Sam Heinz
9d03c20aaa [TB] Change DownloadHelper to use download.FileName
Also adds the UpdateFileName function to DownloadHelper & DownloadData to push FileName to DB
2024-12-10 23:47:55 +10:00
Sam Heinz
dffce96a45 [TB] Add default for fileName in DownloadHelper 2024-12-10 15:25:30 +10:00
Sam Heinz
c34c62f879 [TB] Move handling filenames from DownloadHelper to TorrentClients 2024-12-10 15:10:55 +10:00
Roger Versluis
ee5b5f8dc3 Upgrade to .NET 9, code cleanup. 2024-11-18 03:39:12 -07:00
YvesPa
d15b1a2c01 some changes for tests 2024-10-15 18:27:11 +02:00
YvesPa
c6beedf675 Correct RealDebrid renaming sometimes 2024-09-25 18:07:34 +02:00
Sam Heinz
446b1c0180 Fix error from merge from upstream, fix error on processing 2024-09-12 19:52:03 +10:00
Sam Heinz
0987b1f18c Merge remote-tracking branch 'upstream/master' 2024-09-08 23:57:33 +10:00
Roger Far
35f959ee26 Fixed the DownloadHelper creating ghost folders. Also don't delete the file when starting a symlink download.
Some checks failed
Docker Image CI / build (push) Has been cancelled
2024-09-03 19:59:21 -06:00
Roger Far
b66b864cae Revert "Prevent creation of download folders when using the symlink downloader."
This reverts commit 078bbe4bfb.
2024-09-03 19:14:36 -06:00
Roger Far
078bbe4bfb Prevent creation of download folders when using the symlink downloader. 2024-09-02 21:08:00 -06:00
Sam Heinz
c34f91fc27 Add UI elements for TorBox, fix downloads. 2024-08-28 17:05:56 +10:00
Roger Far
8dd0eec654 Add retry handler with polly to intercept 429 rate limit errors with Real-Debrid. 2024-07-13 19:54:36 -06:00
Roger Far
a78ff95643 Try using the file/folder structure when downloading. 2024-01-21 22:35:28 -07:00
Roger Far
c83982a4d4 Add setting for aria2 to accomodate a download path that is different in aria2 than in rdt-client. 2024-01-05 14:30:49 -07:00
Roger Far
6ad51b036e Store the torrent name instead of the hash to the blackhole directory. 2024-01-05 10:37:07 -07:00
Roger Versluis
ee88fb50f5 Remove illegal characters from the download path. 2023-09-02 16:05:29 -06:00
Roger Versluis
a1e9b00d2d Remove illegal characters from the download path. 2023-09-02 16:04:51 -06:00
Roger Far
e3b38d2834 Add nullable to the projects. 2022-05-13 18:51:04 -06:00
Roger Far
cd6002b5d6 Upgrade packages
Moved C# code to file scoped namespaces
Merged Startup.cs and Program.cs
2022-04-30 11:22:15 -06:00
Roger Far
3ee687f615 Created a separate page for torrent into, added download retrying per file. 2021-07-18 22:46:17 -06:00