Add media info filters

This commit is contained in:
Ben Adrian Sarmiento
2024-06-05 19:19:03 +02:00
parent fa26553933
commit c63ce8da0a
7 changed files with 265 additions and 58 deletions

View File

@@ -136,22 +136,23 @@ func (t *TorrentManager) binOnceDoneErrorCheck(torrentId, status string) bool {
// binOnceDone checks if the torrent is in the OnceDoneBin and deletes it if it is.
// returns true if the torrent was in the bin and was deleted, false otherwise
func (t *TorrentManager) binOnceDone(torrentId string) bool {
if t.OnceDoneBin.Contains(torrentId) {
if err := t.api.DeleteTorrent(torrentId); err != nil {
t.repairLog.Warnf("Failed to delete torrent %s: %v", torrentId, err)
func (t *TorrentManager) binOnceDone(completedTorrentId string) bool {
if t.OnceDoneBin.Contains(completedTorrentId) {
if err := t.api.DeleteTorrent(completedTorrentId); err != nil {
t.repairLog.Warnf("Failed to delete torrent %s: %v", completedTorrentId, err)
}
t.deleteInfoFile(torrentId)
t.OnceDoneBin.Remove(torrentId)
t.deleteInfoFile(completedTorrentId)
t.OnceDoneBin.Remove(completedTorrentId)
t.persistBins()
return true
}
// special case: yyy-xxx means if yyy is done, delete xxx
specialCase := fmt.Sprintf("%s-", torrentId)
specialCase := fmt.Sprintf("%s-", completedTorrentId)
if !t.OnceDoneBin.Contains(specialCase) {
return false
}
t.OnceDoneBin.Remove(specialCase)
t.OnceDoneBin.Clone().Each(func(entry string) bool {
if strings.Contains(entry, specialCase) {
idToDelete := strings.Split(entry, "-")[1]
@@ -162,7 +163,7 @@ func (t *TorrentManager) binOnceDone(torrentId string) bool {
}
return false
})
t.deleteInfoFile(torrentId)
t.deleteInfoFile(completedTorrentId)
t.OnceDoneBin.Remove(specialCase)
t.persistBins()
return true