adjustments
This commit is contained in:
@@ -22,7 +22,7 @@ func (t *TorrentManager) fixerAddCommand(trigger, command string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TorrentManager) processFixers(instances []realdebrid.Torrent) {
|
func (t *TorrentManager) processFixers(instances []realdebrid.Torrent) {
|
||||||
t.log.Debugf("Processing fixers (%d left)", t.fixers.Count())
|
t.log.Debugf("Processing fixers (%d left: %v)", t.fixers.Count(), t.fixers)
|
||||||
var toDelete []string
|
var toDelete []string
|
||||||
var toRedownload []*Torrent
|
var toRedownload []*Torrent
|
||||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ func (ls *LibraryState) Eq(a LibraryState) bool {
|
|||||||
if ls.TotalCount == 0 || ls.FirstActiveTorrentId == "" || ls.FirstTorrentId == "" {
|
if ls.TotalCount == 0 || ls.FirstActiveTorrentId == "" || ls.FirstTorrentId == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if a.TotalCount != ls.TotalCount || a.ActiveCount != ls.ActiveCount || a.FirstActiveTorrentId != ls.FirstActiveTorrentId || a.FirstTorrentId != ls.FirstTorrentId {
|
return a.TotalCount == ls.TotalCount && a.ActiveCount == ls.ActiveCount && a.FirstActiveTorrentId == ls.FirstActiveTorrentId && a.FirstTorrentId == ls.FirstTorrentId
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TorrentManager) setNewLatestState(checksum LibraryState) {
|
func (t *TorrentManager) setNewLatestState(checksum LibraryState) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
|
|||||||
RemountTrigger: make(chan struct{}, 1),
|
RemountTrigger: make(chan struct{}, 1),
|
||||||
allAccessKeys: mapset.NewSet[string](),
|
allAccessKeys: mapset.NewSet[string](),
|
||||||
latestState: &LibraryState{},
|
latestState: &LibraryState{},
|
||||||
requiredVersion: "0.9.3-hotfix.4",
|
requiredVersion: "0.9.3-hotfix.10",
|
||||||
workerPool: workerPool,
|
workerPool: workerPool,
|
||||||
log: log,
|
log: log,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,14 +137,16 @@ func (t *TorrentManager) StartRefreshJob() {
|
|||||||
// getMoreInfo gets original name, size and files for a torrent
|
// getMoreInfo gets original name, size and files for a torrent
|
||||||
func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
|
func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
|
||||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||||
|
|
||||||
if torrentFromCache, exists := infoCache.Get(rdTorrent.ID); exists &&
|
if torrentFromCache, exists := infoCache.Get(rdTorrent.ID); exists &&
|
||||||
!torrentFromCache.AnyInProgress() &&
|
!torrentFromCache.AnyInProgress() &&
|
||||||
torrentFromCache.SelectedFiles.Count() == len(rdTorrent.Links) {
|
torrentFromCache.SelectedFiles.Count() == len(rdTorrent.Links) {
|
||||||
return torrentFromCache
|
return torrentFromCache
|
||||||
|
|
||||||
} else if !exists {
|
} else if !exists {
|
||||||
torrentFromFile := t.readTorrentFromFile(rdTorrent.ID)
|
torrentFromFile := t.readTorrentFromFile(rdTorrent.ID)
|
||||||
|
|
||||||
if torrentFromFile != nil &&
|
if torrentFromFile != nil &&
|
||||||
!torrentFromFile.AnyInProgress() &&
|
|
||||||
torrentFromFile.SelectedFiles.Count() == len(rdTorrent.Links) {
|
torrentFromFile.SelectedFiles.Count() == len(rdTorrent.Links) {
|
||||||
|
|
||||||
hasBrokenFiles := false
|
hasBrokenFiles := false
|
||||||
@@ -158,8 +160,7 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
|
|||||||
infoCache.Set(rdTorrent.ID, torrentFromFile)
|
infoCache.Set(rdTorrent.ID, torrentFromFile)
|
||||||
t.ResetSelectedFiles(torrentFromFile)
|
t.ResetSelectedFiles(torrentFromFile)
|
||||||
return torrentFromFile
|
return torrentFromFile
|
||||||
} else {
|
|
||||||
t.log.Warnf("Torrent %s has broken files, will not save on info cache", rdTorrent.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,8 +226,11 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
|
|||||||
torrent.InProgressIDs.Add(info.ID)
|
torrent.InProgressIDs.Add(info.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
infoCache.Set(rdTorrent.ID, &torrent)
|
// save to cache if it's not in progress anymore
|
||||||
t.saveTorrentChangesToDisk(&torrent, nil)
|
if info.Progress == 100 {
|
||||||
|
infoCache.Set(rdTorrent.ID, &torrent)
|
||||||
|
t.saveTorrentChangesToDisk(&torrent, nil)
|
||||||
|
}
|
||||||
|
|
||||||
return &torrent
|
return &torrent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ func (t *Torrent) AnyInProgress() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) AllInProgress() bool {
|
func (t *Torrent) AllInProgress() bool {
|
||||||
return t.DownloadedIDs.IsEmpty()
|
return t.DownloadedIDs.IsEmpty() && !t.InProgressIDs.IsEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) ComputeTotalSize() int64 {
|
func (t *Torrent) ComputeTotalSize() int64 {
|
||||||
|
|||||||
Reference in New Issue
Block a user