Fix rewrites

This commit is contained in:
Ben Sarmiento
2024-05-22 02:26:20 +02:00
parent a9cc689702
commit 9990bf90ca
10 changed files with 149 additions and 114 deletions

View File

@@ -1,16 +1,29 @@
package torrent
import "github.com/debridmediamanager/zurg/pkg/logutil"
type LibraryState struct {
TotalCount int
ActiveCount int
FirstTorrentId string
log *logutil.Logger
}
func (ls *LibraryState) Eq(a LibraryState) bool {
if ls.TotalCount == 0 || ls.FirstTorrentId == "" {
ls.log.Debugf("Checksum is empty")
return false
} else if a.TotalCount != ls.TotalCount {
ls.log.Debugf("Checksum total count mismatch: %d != %d", a.TotalCount, ls.TotalCount)
return false
} else if a.ActiveCount != ls.ActiveCount {
ls.log.Debugf("Checksum active count mismatch: %d != %d", a.ActiveCount, ls.ActiveCount)
return false
} else if a.FirstTorrentId != ls.FirstTorrentId {
ls.log.Debugf("Checksum first torrent id mismatch: %s != %s", a.FirstTorrentId, ls.FirstTorrentId)
return false
}
return a.TotalCount == ls.TotalCount && a.ActiveCount == ls.ActiveCount && a.FirstTorrentId == ls.FirstTorrentId
return true
}
func (t *TorrentManager) setNewLatestState(checksum LibraryState) {