Repository navigation
fix(torrent): save names Windows can't take under ones it can - #271
Merged
anmolkapil merged 1 commit intoNov 18, 2026
Merged
Conversation
A torrent named with a "|" (or a folder ending in a dot or a space, or a device name like CON) was refused on Windows as soon as it was added. Such names are now saved the way other clients save them: a folder's forbidden characters become "_", trailing dots and spaces go, and a device name gets a "_" in front. A name too long for any file system is shortened, its extension kept. A renamed name that meets another in its folder is told apart as "Name (2)". The storage is handed these paths, so the files are where the checks, the file list and removal expect them, and the same torrent always maps to the same names: a resumed download finds its pieces again. Fixes anmolkapil#202
anmolkapil
approved these changes
Nov 18, 2026
anmolkapil
left a comment
Owner
There was a problem hiding this comment.
Thanks Arpit, reviewed and tested locally. Agree on showing the saved names in the file list. Merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #202
What was wrong
When a torrent is added, Plexo checks every path in it before writing anything (
safeTorrentPathsinsrc/main/download/torrent/paths.ts). On Windows it refused the whole torrent if any part of a path was a name Windows can't save. That's where "Windows can't save a file named …" comes from.In my first reply on #202 I said this was about names ending in a space or a dot. That was only part of it. Here's what happened on Windows for each kind of name:
<>:"|?*or a control character, including the torrent's own name (its top folder)<>:"|?*.or a spaceCON,NUL,COM1,LPT²,CON.txt…)In #202 the error names
[Trix] Blue Box S01 v3 (WEB 1080p AV1 Opus) [Multi Subs]. That's the torrent's own name, which differs from the magnet'sdn(… [Multi Subs] | Ao no Hako (VOSTFR) (Batch)). Either a|after[Multi Subs]or a trailing space would produce that error. Both are covered by the tests below.What it does now
Names that can be mapped are saved under one that works, the way qBittorrent and libtorrent handle it. Only Windows changes, apart from over-long names, which no system can save:
_, soBlue Box | Ao no Hakois saved asBlue Box _ Ao no Hako. In a file name they're still dropped, as webtorrent has always done. I kept that so downloads already in progress on Windows resume against the same files.Season 1.becomesSeason 1. A name made only of dots and spaces becomes_._in front:CON.txtbecomes_CON.txtandNULbecomes_NUL. HTTP downloads (claimName) and NZB files already do this, so I matched them instead of adding a suffix.Name (2). This covers names in one folder, or in folders that differ only by case or by how an é is written, since those are one folder on Windows and macOS. The name that didn't need changing keeps its name:x./aandx/bare saved asx (2)/aandx/b. Each folder is renamed once, so every file in it ends up in the same place. The saved paths are then checked again for collisions.A torrent is still refused when:
..) or is absoluteA.txtanda.txt, or é written two ways, as in fix: refuse torrent files that differ only by Unicode normalization #179)The mapping depends only on the torrent's file list, so the same torrent always gets the same paths. That matters because the paths are worked out again on restore and on relaunch.
How
safeTorrentPathsreturns the paths the files will be saved at, instead of throwing. Everything that already reads the probe'sfilesfollows them automatically: the file list in the window, removing the files you didn't choose, and cancel and remove.storeNamed) used to split webtorrent's ownfile.pathagain. It now receives the checked paths in the torrent's order. Downloading, the hash check on resume and seeding all read and write through that store, so they all use the same files.Tests
e2e/torrent.spec.ts, "names a system can't save": a torrent seeded from memory, so the test's seeder never has to write those names to disk.[Trix] Blue Box | Ao no Hako(a|and a trailing space). Inside:Season 1. /01 | Episode.mkv,Extras|Bonus/notes.,CON.txt,report.txt(trailing space),NUL, andx./a.binnext tox/b.bin. The saved names expected on each platform are written out by hand.e2e/torrentPaths.spec.ts:Results:
Windows can't save a file named [Trix] Blue Box | Ao no Hako.torrentPathscases fail too.torrentPaths,torrent,torrentProbe,torrentNative,torrentTrackers,torrentPeers,torrentFiles,removal); only the two-network tests skip, as they do on CI.downloadActionsall pass. Without the folder-case fix, the case/Unicode cases intorrentPathsfail.typecheck:node,typecheck:web,typecheck:e2e,lint,format:checkandelectron-vite buildall pass.For you to decide
_CON.txt), not the torrent's own name. That seemed more honest than showing a name that won't exist on disk.