Cleanup bins
This commit is contained in:
@@ -38,6 +38,7 @@ func (t *TorrentManager) refreshTorrents() []string {
|
||||
freshAccessKeys := mapset.NewSet[string]()
|
||||
|
||||
for i := range instances {
|
||||
freshIDs.Add(instances[i].ID)
|
||||
wg.Add(1)
|
||||
idx := i
|
||||
_ = t.workerPool.Submit(func() {
|
||||
@@ -52,8 +53,6 @@ func (t *TorrentManager) refreshTorrents() []string {
|
||||
return
|
||||
}
|
||||
|
||||
freshIDs.Add(instances[idx].ID)
|
||||
|
||||
tInfo := t.getMoreInfo(instances[idx])
|
||||
torrent := t.convertToTorrent(tInfo)
|
||||
accessKey := t.GetKey(torrent)
|
||||
@@ -124,14 +123,21 @@ func (t *TorrentManager) refreshTorrents() []string {
|
||||
|
||||
t.log.Infof("Compiled into %d unique torrents", allTorrents.Count())
|
||||
|
||||
// delete info files that are no longer present
|
||||
t.getInfoFiles().Each(func(path string) bool {
|
||||
path = filepath.Base(path)
|
||||
torrentID := strings.TrimSuffix(path, ".zurginfo")
|
||||
if !t.binOnceDone(torrentID) && !freshIDs.Contains(torrentID) {
|
||||
t.deleteInfoFile(torrentID)
|
||||
}
|
||||
return false
|
||||
t.workerPool.Submit(func() {
|
||||
// delete info files that are no longer present
|
||||
t.getInfoFiles().Each(func(path string) bool {
|
||||
path = filepath.Base(path)
|
||||
torrentID := strings.TrimSuffix(path, ".zurginfo")
|
||||
// if binOnceDone returns true, it means the info file is deleted
|
||||
// if false, then we check if it's one of the torrents we just fetched
|
||||
// if not, then we delete the info file
|
||||
if !t.binOnceDone(torrentID) && !freshIDs.Contains(torrentID) {
|
||||
t.deleteInfoFile(torrentID)
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
t.cleanupBins(freshIDs)
|
||||
})
|
||||
|
||||
return updatedPaths.ToSlice()
|
||||
|
||||
Reference in New Issue
Block a user