Skip to main content

Orphan Scan

Orphan scan finds and removes files in your download directories that no torrent references.

How it works​

  1. qui builds the scan roots from the save paths of your current torrents. It does not scan qBittorrent's default save path unless you turn on Scan Default Save Path.
  2. qui flags files that no torrent references as orphans. A file a torrent references also protects the other paths to it that the scan reaches through a bind mount or a symlinked folder, as long as the scan reaches the torrent's file too. Such a path has the same file name and the same folder as the torrent's file. A hardlink of a torrent's file is a separate entry in a folder, so qui lists it as an orphan. If you delete a hardlink, the torrent keeps its file. You free no space, because the torrent's file holds the same data.
  3. Before you confirm deletion, you preview the list.
  4. qui re-checks each listed file against the files your torrents use now, by path and by file identity. A file that a torrent started to use through a bind mount or a symlinked folder since the preview stays. qui deletes a hardlink of such a file, and the torrent keeps its own file. A listed folder that a torrent now reaches through another path stays too, even when the torrent has not written anything yet. qui reads the folders along your torrents' paths only when the preview lists a folder. A file or folder your torrents use that is missing protects nothing, because qBittorrent cannot read it either. The same goes for a path that runs into a symbolic link loop. On Windows, qui treats any link that Windows reports it cannot resolve the same way, which assumes that qBittorrent cannot read that path either. qui logs a warning when it skips a path for either reason. The system sometimes reports such a path as missing instead, and then no warning appears. qui skips a file your torrents use when it is not allowed to look it up, so another path to it is not protected. If qui is not allowed to look up a folder that your torrents use, the deletion stops before qui deletes anything, because qBittorrent could reach a listed folder through it. The deletion also stops if qui cannot read one of those files or folders for any other reason. This includes a file that qui can look up but whose file identity it is not allowed to read, for example because of a Windows ACL.
  5. qui deletes the files, then removes the directories the preview listed.
note

When matching paths, qui normalizes Unicode paths to canonical NFC form. If the filesystem and qBittorrent report composed and decomposed forms of the same name, this normalization prevents false orphans. On normalization-sensitive filesystems, qui treats two byte-distinct canonical-equivalent names as one logical path.

info

If multiple active qBittorrent instances see the same files and their torrent save paths overlap, qui also protects files that torrents from those other instances reference. qui applies this protection even when it scans a single instance.

For a scan with Local Filesystem Access, the other instances are those with local filesystem access. If the scanned instance also has SSH settings, the instances with SSH settings for the same server count too. For a scan of a remote instance, they are the instances with SSH settings for the same server. See Remote instances.

To protect files safely, qui must determine whether the scan paths overlap. If any of those other instances is unreachable or not ready, the scan fails to prevent false positives.

warning

qui does not protect disabled instances. If a disabled instance shares save paths with an active instance, qui can flag its files as orphans. Before you scan, enable the instance or make sure that the paths do not overlap.

Docker: Local Filesystem Access

Orphan scan, hardlinks, reflinks, and path-based automation rules require access to the same filesystem paths that qBittorrent uses.

Mount the same paths that qBittorrent uses. The paths must match exactly:

volumes:
- ./qui:/config
- /data/torrents:/data/torrents # Must match qBittorrent's path

After you mount the paths, enable Local Filesystem Access on each instance in qui's Instance Settings.

Remote instances​

Orphan scan also works on a remote instance, which is an instance whose files qui reaches over SSH. A scan, its preview, and the CSV export work the same as on a local instance. All paths, for example ignore paths, are paths on the remote machine.

Deletion​

Deletion and auto-cleanup need file identity. File identity tells qui when two paths are the same file.

  • On a remote instance where qui can run commands on the host, deletion and auto-cleanup work under the same rules as on a local instance. They work only for a scan that read the identity of every file. If the scan could not do that, the run shows a warning, and you can only preview and export the list. This happens when find fails on the server, when a scanned folder holds too many entries to read at one time, or when files change while qui reads them. Run a new scan.
  • On a remote instance where qui only has SFTP, you can only preview and export. Use the exported list to remove the files on the server yourself. qui reads no file identity there. A file that a torrent uses can show in the preview when the scan also reaches it at a second path, for example through a bind mount. The rule in Abandoned directories for a folder that a torrent reaches through a symbolic link or a bind mount also does not apply. Such a folder can show in the preview. qui removes nothing on such an instance.

Before a delete, qui reads over SSH the identity of every file that the torrents use. If the connection drops during that read, the delete stops before qui removes anything. If the connection drops later, during the delete, qui continues with the files that it can still reach. The next scan lists what is left.

A scan belongs to its SSH settings​

A scan is valid only for the SSH user, host, port, and host key that it used. If you save the SSH settings (also without a change), remove them, or replace the host key, qui does not delete from the earlier scan, and its preview fails. Run a new scan. While a delete runs, qui refuses these three changes.

If you switch an instance between local and SSH access after a scan, also run a new scan before you delete.

Other instances on the same server​

The torrents of another active instance protect files in a scan of a remote instance only when that instance has SSH settings for the same server. Two instances are on the same server when they have the same SSH host and port, or the same pinned host key. For example, you save one instance with the IP address of the server and one with its hostname. After you confirm the host key on both, each instance protects the files of the other. The other instance needs no complete SSH access for this.

The torrents of an instance without SSH settings for the same server do not protect files in the scan of a remote instance, also when that instance has Local Filesystem Access. qui compares paths, and the same path on two machines is not the same file.

Directories no torrent points at​

By default, qui scans a directory only if at least one torrent points to it. If you delete all torrents from a directory, that directory stops being a scan root. qui does not detect leftover files there.

Example: You have torrents in /downloads/old-stuff/. If you delete all those torrents, orphan scan stops tracking /downloads/old-stuff/ and does not clean it up.

The same gap applies one level up. If your torrents all save to /data/torrents/mydata/, a stray /data/torrents/test.txt is never walked, because no torrent points at /data/torrents/.

For a directory outside the default save path and outside each category path, keep one small torrent with its save path in that directory. Orphan scan then walks the directory and all its subdirectories. The save path must match the case of the directory name. On Linux, if the save path is /data/mtv and the directory is /data/MTV, qBittorrent makes a second, empty mtv directory and moves the torrent into it. The scan then walks the new directory and reports it as clean.

Scanning the default save path​

Turn on Scan Default Save Path to close that gap. qui reads the default save path from the instance's own qBittorrent settings and walks it as a scan root, including subdirectories that no torrent uses.

Turn on Including Category Paths underneath it to also walk every category destination: the save path a category sets, or default save path / category name for a category that inherits it. This matters when a category points somewhere outside the default save path, which the first toggle alone would not reach. It is available only while Scan Default Save Path is on.

Both are off by default. Turning them on widens what a scan can flag, so review the preview before you confirm a deletion.

Everything else still applies inside the wider roots:

  • Files that torrents reference are protected, including torrents on the other active instances that see the same files. See How it works.
  • Ignore paths, the grace period, and max items per run all apply.
  • A save path missing from disk, such as an unmounted volume, is reported rather than treated as scanned, even when a wider root covers it.

If qui cannot read the default save path or the category list from qBittorrent, or qBittorrent reports an empty or relative default save path, or a relative download path that a protected folder depends on, the run fails and names the cause. qui does not fall back to a narrower scan, because a narrower scan would report a clean result over a tree you asked it to check.

note

These paths come from qBittorrent, so they are paths as qBittorrent sees them. If qui runs in a different container, they must resolve to the same directories on the host that runs qui.

Abandoned directories​

Moves and deletions leave empty directories behind. qui removes the leftover folders of the deletes and moves it makes or proxies itself (see Deleting and moving torrents). Deletes made in the qBittorrent WebUI, by qBittorrent's share limits, or by a client that bypasses the proxy still leave them. Orphan scan reports files, so an empty directory is never flagged, and the tree fills up with them over time.

Turn on Delete Abandoned Directories to include them. qui reports a directory when this run empties it: either it holds no files at any depth, or every file below it is an orphan the run is about to delete. Each one is listed in the preview alongside the orphan files, marked with a directory icon and no size.

A single file that survives the run keeps its whole chain of parent directories. That covers a file a torrent owns, a file still inside the grace period, a file under your ignore paths, and a file the max-items cap pushed out of this run.

These are never reported, even when empty:

  • A scan root itself.
  • A category destination, or any directory above one. qBittorrent will save into it again. qui works out a category's directory the same way qBittorrent does, including one that inherits from a parent category.
  • The download path while it is turned on, a category's download folder, or any directory above one. qBittorrent will download into it again. qui works out a category's download folder the same way qBittorrent does: its own download path, the one it takes from its parent category, or its folder in its parent category's download folder or in the download path, even when the download path is turned off.
  • A folder that qBittorrent monitors for .torrent files, the save path set for it, or any directory above one. If qui removes a monitored folder, qBittorrent stops watching it until qBittorrent restarts.
  • Anything under your ignore paths.
  • A directory changed more recently than the grace period.
  • A directory holding anything qui did not itself list for removal, such as an ignored subdirectory, a symbolic link or a Windows junction.
  • A directory that a torrent's save path, or a folder inside the torrent, reaches through a symbolic link, a bind mount or a Windows junction, and any directory that holds one. This holds even before the torrent writes anything. If qui cannot read one of those folders for a reason other than a missing folder, a symbolic link loop or a link that Windows reports it cannot resolve, it lists no directory in that run, and the run is a partial scan. This includes a folder that qui is not allowed to look up, because a torrent could reach a listed directory through it.

On every platform, orphan file scans skip symbolic links and other non-regular entries, including sockets, FIFOs (named pipes) and devices. On Windows, this also excludes junctions. When a torrent's save path is itself a symbolic link to a folder, qui reads the folder through the link only to learn which files the torrent uses, and does not list those files where it finds them at the link's target. Nothing is listed or deleted through the link. Recognized cloud-placeholder files and Windows Overlay Filter (WOF) data files remain eligible for file scanning and deletion. WOF supports compressed files. Normal access permissions still apply. Windows uses reparse tags to identify files that need special filesystem handling. Unknown reparse tags remain excluded.

On every platform, confirmed deletion also keeps a symbolic link or containing directory when a torrent references a file beneath that path. This preserves the path the torrent uses, even when removing the link would leave the target's bytes intact.

qui lists a Blu-ray or DVD folder (BDMV or VIDEO_TS) as one item. If that folder holds a symbolic link to a file that a torrent uses, deletion keeps the whole folder, even when the torrent uses its own path to the file and not the link. The run reports "a torrent now uses a file in this folder through another path", and each new scan lists the folder again. Remove the link to let qui delete the folder.

Directories are removed after the files, so a tree this run empties goes in one pass. qui removes only the directories the preview listed, so the directory count never exceeds what you saw. Anything that changed between the preview and your confirmation is skipped rather than removed: a directory that still holds a file the run kept, one that gained content, one a torrent now reaches through another path, or one that has since become a scan root, a category destination or a monitored folder is reported as skipped, not failed.

Partial scans​

A directory can disappear while a scan runs, for example when an automation removes a torrent and its files. If a directory below a scan path disappears, qui skips that directory and scans the rest of the path. If at least one scan path completes but another is unavailable, qui reports Partial scan and keeps the results from completed paths. This also applies when qui skips paths because qBittorrent temporarily cannot provide torrent file lists. This result applies even when qui finds no orphan files.

The run details and deletion preview show the warning with the affected paths and reasons. The selected scan paths list includes paths that failed during scanning. Paths skipped before scanning appear in the warning.

Partial scans skip automatic cleanup. You can review the warning and delete the listed orphan files manually. Before deletion, qui refreshes torrent ownership data, re-checks the listed files as How it works describes, and applies its normal deletion checks. After successful manual deletion, the run keeps its Partial scan label. If all deletion attempts fail, the run shows Failed and keeps both the scan warning and the deletion error.

If you enable orphan-scan completion notifications, partial scans send a warning through that setting, including when results await manual review. The completion notification after manual deletion also includes the scan warning.

Use Scan Now to try again, or wait for the next scheduled scan. qui does not retry immediately. If paths are unavailable or skipped and no scan path completes, the run fails. The run also fails if qui cannot establish torrent ownership. qui ignores a missing default or category path only if no torrent uses the same path as a scan root. Otherwise, qui reports the path as unavailable.

Settings​

SettingDescriptionDefault
Grace periodSkip files modified within this window10 minutes
Ignore pathsDirectories to exclude from scanning-
Scan intervalHow often scheduled scans run24 hours
Max items per runMaximum orphan preview entries, files and directories together, saved for a run (also caps what qui can delete from that run)1,000
Scan default save pathAlso walk qBittorrent's default save path, including directories no torrent usesDisabled
Including category pathsAlso walk every category destination, explicit or inheritedDisabled
Delete abandoned directoriesReport directories this run emptiesDisabled
Auto-cleanupDelete orphans from complete scheduled scans without manual confirmationDisabled
Max files thresholdIf the orphan file count is at or below this threshold, auto-delete orphans. Directories do not count.100
Default ignores

Orphan scan skips common OS and NAS metadata, recycle bin, snapshot, and Kubernetes volume-internal entries. Matching is case-insensitive.

Ignored files (exact names)

  • .DS_Store
  • .directory
  • desktop.ini
  • Thumbs.db

Ignored files (name prefixes)

  • .fuse* (for example .fuse_hidden*)
  • .nfs*
  • ._*
  • .goutputstream-*
  • .#*
  • ~$*

Ignored files (name suffixes)

  • *.parts (qBittorrent partial download files)
  • *.!qB (qBittorrent incomplete download files)

Ignored directories (exact names)

  • .AppleDB
  • .AppleDouble
  • .TemporaryItems
  • .Trashes
  • .Recycle.Bin
  • .recycle
  • .snapshot
  • .snapshots
  • .zfs
  • @eaDir
  • $RECYCLE.BIN
  • #recycle
  • lost+found
  • System Volume Information

Ignored directories (name prefixes)

  • .Trash-*
  • ..* (Kubernetes internals like ..data and timestamp dirs)

If you keep hardlinks of torrent files inside a scan root on purpose, for example a media library below a save path, add an ignore path for that folder. Otherwise qui lists each of those hardlinks as an orphan, and auto-cleanup can delete them with no confirmation.

If an ignore path is a scan path, or a directory above a scan path, qui removes that scan path from the run. Use this when a save path is not available on the host that runs qui. qui still reads an ignore path that is a torrent's file or holds one, and an ignored save path that is a symbolic link to a folder, to learn which files the torrents use. A second path to one of those files elsewhere, such as a bind mount, is then not flagged. qui lists nothing there. If such a path is missing, qui skips it. If qui cannot read it for another reason, the run is a partial scan. If the ignore paths remove all scan paths, the run fails and tells you that the ignore paths cover every scan path. Filesystem-root ignore paths keep the scan paths in the run, but files under those roots are ignored. Paths on other drives or shares are still scanned normally. If the ignores cover every scan path, an otherwise successful run completes with no orphans.

Max items per run behavior​

  1. qui attempts to scan all selected paths. A wider directory can cover nested scan paths. Unavailable paths follow the partial scan rules.
  2. qui sorts the orphan candidates by your selected preview sort.
  3. qui applies Max items per run. If more candidates exist than the cap, qui marks the run as truncated.
  4. qui deletes only the items saved in that run's preview list: orphan files and the abandoned directories they empty.

Example: If qui finds 2,000 orphan candidates among 5,000 total files and Max items per run is 1,000, qui scans all 5,000 files, saves the top 1,000 candidates for preview and deletion, and marks the run as truncated.

FAQ​

Do I need multiple runs to scan everything? No. qui applies the preview cap after scanning. If orphan candidates exceed the cap, delete the items in the current preview first. The next scan returns the next set of candidates. If paths were unavailable, restore access and run another scan.

Workflow​

  1. Trigger a manual or scheduled scan.
  2. Review the preview list of orphan files and directories.
  3. Confirm deletion.
  4. qui deletes the files, then removes the directories you saw in the preview.

Preview features​

  • Path column: Shows the full file path with copy-to-clipboard support.
  • Export CSV: Downloads the full preview list across all pages as a CSV file.