Skip to content

feat(orphan): implement categories - #98

Open
KyleSanderson wants to merge 3 commits into
mainfrom
feat/orphaned/categories
Open

feat(orphan): implement categories#98
KyleSanderson wants to merge 3 commits into
mainfrom
feat/orphaned/categories

Conversation

@KyleSanderson

Copy link
Copy Markdown

No description provided.

@s0up4200

s0up4200 commented Nov 2, 2025

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +225 to +244
// 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread cmd/orphan.go
Comment on lines +423 to +433
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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants