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

@@ -52,7 +52,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
deleteOnceDone: mapset.NewSet[string](),
allAccessKeys: mapset.NewSet[string](),
latestState: &LibraryState{},
requiredVersion: "24.01.2024",
requiredVersion: "27.01.2024",
workerPool: workerPool,
repairPool: repairPool,
log: log,

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]()

View File

@@ -6,7 +6,7 @@ import (
mapset "github.com/deckarep/golang-set/v2"
)
func (t *TorrentManager) getUncachedTorrents() ([]*Torrent, error) {
func (t *TorrentManager) GetUncachedTorrents() ([]*Torrent, error) {
t.log.Debug("Checking if torrents are still cached")
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)