Continue on delete failure for bins

This commit is contained in:
Ben Sarmiento
2024-05-27 21:40:44 +02:00
parent 0c64cda1d8
commit 5e204695df
2 changed files with 8 additions and 18 deletions

View File

@@ -89,8 +89,7 @@ func (t *TorrentManager) setXToBinOnceYDone(deleteId, completeId string) {
func (t *TorrentManager) binImmediately(torrentId string) bool {
if t.ImmediateBin.Contains(torrentId) {
if err := t.api.DeleteTorrent(torrentId); err != nil {
t.repairLog.Errorf("Failed to delete torrent %s: %v", torrentId, err)
return false
t.repairLog.Warnf("Failed to delete torrent %s: %v", torrentId, err)
}
t.ImmediateBin.Remove(torrentId)
t.persistBins()
@@ -109,8 +108,7 @@ func (t *TorrentManager) binOnceDoneErrorCheck(torrentId, status string) bool {
func (t *TorrentManager) binOnceDone(torrentId string) bool {
if t.OnceDoneBin.Contains(torrentId) {
if err := t.api.DeleteTorrent(torrentId); err != nil {
t.repairLog.Errorf("Failed to delete torrent %s: %v", torrentId, err)
return false
t.repairLog.Warnf("Failed to delete torrent %s: %v", torrentId, err)
}
t.OnceDoneBin.Remove(torrentId)
t.persistBins()
@@ -122,23 +120,17 @@ func (t *TorrentManager) binOnceDone(torrentId string) bool {
if !t.OnceDoneBin.Contains(specialCase) {
return false
}
hasError := false
t.OnceDoneBin.Clone().Each(func(entry string) bool {
if strings.Contains(entry, specialCase) {
idToDelete := strings.Split(entry, "-")[1]
if err := t.api.DeleteTorrent(idToDelete); err != nil {
t.repairLog.Errorf("Failed to delete torrent %s: %v", idToDelete, err)
hasError = true
return true
t.repairLog.Warnf("Failed to delete torrent %s: %v", idToDelete, err)
}
t.OnceDoneBin.Remove(entry)
}
return false
})
if !hasError {
t.OnceDoneBin.Remove(specialCase)
}
t.OnceDoneBin.Remove(specialCase)
t.persistBins()
return true
}

View File

@@ -67,12 +67,10 @@ func (t *TorrentManager) invokeRepair(torrent *Torrent) {
t.repairRunningMu.Unlock()
// before we let go, let's check repairQueue
t.workerPool.Submit(func() {
queuedTorrent, exists := t.repairQueue.Pop()
if exists {
t.TriggerRepair(queuedTorrent)
}
})
queuedTorrent, exists := t.repairQueue.Pop()
if exists {
t.TriggerRepair(queuedTorrent)
}
}
// TriggerRepair allows an on-demand repair to be initiated.