feat(orphan): implement categories - #98
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Also check with path mappings applied to torrent path | ||
| if len(torrentPathMapping) > 0 { | ||
| for mapFrom, mapTo := range torrentPathMapping { | ||
| mappedPath := strings.Replace(torrent.Path, mapFrom, mapTo, 1) | ||
| normalizedMappedPath := strings.ToLower(strings.ReplaceAll(mappedPath, "\\", "/")) | ||
|
|
||
| if normalizedMappedPath == normalizedLocalPath { | ||
| if log != nil { | ||
| if logger, ok := log.(interface{ Tracef(string, ...interface{}) }); ok { | ||
| logger.Tracef("Found mapped match for torrent save path: %q -> %q", torrent.Path, mappedPath) | ||
| } | ||
| } | ||
| t.pathCache.Store(localPath, true) | ||
| return true | ||
| } | ||
| } | ||
| } | ||
| } | ||
| // Only check the first torrent since they should all have the same Path for the same hash | ||
| break |
There was a problem hiding this comment.
Handle all torrents when checking directory paths
Within HasPathInCategory the loop that checks torrent save paths breaks after the first map entry. Because of the break, only one torrent’s Path is ever compared, so every other active torrent directory returns false and will be marked as orphan if the directory happens to be empty. This makes category-aware orphan removal treat almost all torrent directories as untracked. Removing the outer break (or iterating over unique paths) would allow every torrent path to be considered.
Useful? React with 👍 / 👎.
| log.Infof("Scanning category: %q with path: %q", categoryName, categoryPath) | ||
|
|
||
| // Check if category path exists | ||
| if _, err := os.Stat(categoryPath); os.IsNotExist(err) { | ||
| log.Warnf("Category path does not exist: %q", categoryPath) | ||
| continue | ||
| } | ||
|
|
||
| // Get all paths in category location | ||
| localPaths, _ := paths.InFolder(categoryPath, true, true, nil) | ||
| log.Debugf("Retrieved %d paths from category path", len(localPaths)) |
There was a problem hiding this comment.
Apply download path mapping when scanning category folders
In category-aware mode the code calls os.Stat and paths.InFolder on the raw values from c.LabelPathMap(). Those paths are reported by the client (e.g. qBittorrent) and are the remote save paths; when the client uses download-path mappings, these directories typically do not exist on the local filesystem. The code therefore logs "Category path does not exist" and skips the category entirely, making the new feature unusable for remote clients with mapped paths. Category paths should be run through clientDownloadPathMapping before interacting with the local filesystem.
Useful? React with 👍 / 👎.
No description provided.