Adjust logging for unplayable dir and assigning directories
This commit is contained in:
@@ -62,7 +62,7 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
|
||||
if !exists {
|
||||
allTorrents.Set(accessKey, torrent)
|
||||
t.writeTorrentToFile(torrent)
|
||||
t.assignDirectory(torrent, !initialRun)
|
||||
t.assignDirectory(torrent, !initialRun, true)
|
||||
} else if !mainTorrent.DownloadedIDs.ContainsOne(tInfo.ID) {
|
||||
forMerging = torrent
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
|
||||
mainTorrent := t.mergeTorrents(existing, torrent)
|
||||
allTorrents.Set(accessKey, mainTorrent)
|
||||
t.writeTorrentToFile(mainTorrent)
|
||||
t.assignDirectory(mainTorrent, !initialRun)
|
||||
t.assignDirectory(mainTorrent, !initialRun, true)
|
||||
}
|
||||
|
||||
// new torrents
|
||||
@@ -344,7 +344,7 @@ func (t *TorrentManager) mergeTorrents(existing, toMerge *Torrent) *Torrent {
|
||||
return mergedTorrent
|
||||
}
|
||||
|
||||
func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool) {
|
||||
func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool, outputLogs bool) {
|
||||
accessKey := t.GetKey(tor)
|
||||
|
||||
t.DirectoryMap.IterCb(func(directory string, torrents cmap.ConcurrentMap[string, *Torrent]) {
|
||||
@@ -372,6 +372,9 @@ func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool) {
|
||||
})
|
||||
|
||||
if unplayable {
|
||||
if outputLogs {
|
||||
t.log.Warnf("No playable files for %s, moving to unplayable directory", accessKey)
|
||||
}
|
||||
t.markAsUnplayable(tor, "no playable files")
|
||||
return
|
||||
}
|
||||
@@ -380,6 +383,7 @@ func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool) {
|
||||
switch t.Config.GetVersion() {
|
||||
case "v1":
|
||||
updatedPaths := make([]string, 0)
|
||||
dirs := make([]string, 0)
|
||||
configV1 := t.Config.(*config.ZurgConfigV1)
|
||||
for _, directories := range configV1.GetGroupMap() {
|
||||
for _, directory := range directories {
|
||||
@@ -387,6 +391,10 @@ func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool) {
|
||||
listing, _ := t.DirectoryMap.Get(directory)
|
||||
listing.Set(accessKey, tor)
|
||||
|
||||
if directory != INT_ALL {
|
||||
dirs = append(dirs, directory)
|
||||
}
|
||||
|
||||
if triggerHook {
|
||||
updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, accessKey))
|
||||
}
|
||||
@@ -397,6 +405,9 @@ func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool) {
|
||||
if triggerHook {
|
||||
OnLibraryUpdateHook(updatedPaths, t.Config, t.log)
|
||||
}
|
||||
if outputLogs {
|
||||
t.log.Infof("Assigned %s to: %s", accessKey, strings.Join(dirs, ", "))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user