Use full path of files

This commit is contained in:
Ben Sarmiento
2024-01-27 00:32:16 +01:00
parent 4bb0234d8f
commit 1c0ae6e27f
3 changed files with 10 additions and 7 deletions

View File

@@ -213,15 +213,18 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
}
torrent.SelectedFiles = cmap.New[*File]()
for _, file := range selectedFiles {
// remove forward slash in the beginning
filename := strings.TrimPrefix(file.Path, "/")
filename = strings.ReplaceAll(filename, "/", " - ")
// todo better handling of duplicate filenames
if torrent.SelectedFiles.Has(filepath.Base(file.Path)) {
oldName := filepath.Base(file.Path)
if torrent.SelectedFiles.Has(filename) {
oldName := filename
ext := filepath.Ext(oldName)
filename := strings.TrimSuffix(oldName, ext)
newName := fmt.Sprintf("%s (%d)%s", filename, file.ID, ext)
noExtension := strings.TrimSuffix(oldName, ext)
newName := fmt.Sprintf("%s (%d)%s", noExtension, file.ID, ext)
torrent.SelectedFiles.Set(newName, file)
} else {
torrent.SelectedFiles.Set(filepath.Base(file.Path), file)
torrent.SelectedFiles.Set(filename, file)
}
}
torrent.DownloadedIDs = mapset.NewSet[string]()