Do not repair if uncached check fails
This commit is contained in:
@@ -74,7 +74,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
return false
|
||||
})
|
||||
|
||||
freshKeys := mapset.NewSet[string]()
|
||||
newlyFetchedKeys := mapset.NewSet[string]()
|
||||
noInfoCount := 0
|
||||
for info := range infoChan {
|
||||
if info == nil {
|
||||
@@ -83,7 +83,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
}
|
||||
accessKey := t.GetKey(info)
|
||||
if !info.AnyInProgress() {
|
||||
freshKeys.Add(accessKey)
|
||||
newlyFetchedKeys.Add(accessKey)
|
||||
}
|
||||
if torrent, exists := allTorrents.Get(accessKey); !exists {
|
||||
allTorrents.Set(accessKey, info)
|
||||
@@ -96,7 +96,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
|
||||
var updatedPaths []string
|
||||
// torrents yet to be assigned in a directory
|
||||
freshKeys.Difference(t.allAccessKeys).Each(func(accessKey string) bool {
|
||||
newlyFetchedKeys.Difference(t.allAccessKeys).Each(func(accessKey string) bool {
|
||||
// assign to directories
|
||||
tor, ok := allTorrents.Get(accessKey)
|
||||
if !ok {
|
||||
@@ -117,7 +117,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
return false
|
||||
})
|
||||
// removed torrents
|
||||
t.allAccessKeys.Difference(freshKeys).Each(func(accessKey string) bool {
|
||||
t.allAccessKeys.Difference(newlyFetchedKeys).Each(func(accessKey string) bool {
|
||||
t.Delete(accessKey, false)
|
||||
return false
|
||||
})
|
||||
@@ -254,11 +254,19 @@ func (t *TorrentManager) mergeToMain(existing, toMerge *Torrent) Torrent {
|
||||
Hash: existing.Hash,
|
||||
DownloadedIDs: mapset.NewSet[string](),
|
||||
InProgressIDs: mapset.NewSet[string](),
|
||||
Unrepairable: existing.Unrepairable || toMerge.Unrepairable,
|
||||
UnassignedLinks: existing.UnassignedLinks.Union(toMerge.UnassignedLinks),
|
||||
BrokenLinks: existing.BrokenLinks.Union(toMerge.BrokenLinks),
|
||||
}
|
||||
|
||||
// unrepairable reason
|
||||
if existing.UnrepairableReason != "" && toMerge.UnrepairableReason != "" && existing.UnrepairableReason != toMerge.UnrepairableReason {
|
||||
mainTorrent.UnrepairableReason = fmt.Sprintf("%s, %s", existing.UnrepairableReason, toMerge.UnrepairableReason)
|
||||
} else if existing.UnrepairableReason != "" {
|
||||
mainTorrent.UnrepairableReason = existing.UnrepairableReason
|
||||
} else if toMerge.UnrepairableReason != "" {
|
||||
mainTorrent.UnrepairableReason = toMerge.UnrepairableReason
|
||||
}
|
||||
|
||||
// this function triggers only when we have a new DownloadedID
|
||||
toMerge.DownloadedIDs.Difference(existing.DownloadedIDs).Each(func(id string) bool {
|
||||
mainTorrent.DownloadedIDs.Add(id)
|
||||
@@ -288,6 +296,18 @@ func (t *TorrentManager) mergeToMain(existing, toMerge *Torrent) Torrent {
|
||||
}
|
||||
})
|
||||
|
||||
// broken links
|
||||
if mainTorrent.BrokenLinks.Cardinality() > 0 {
|
||||
mainTorrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
mainTorrent.BrokenLinks.Each(func(brokenLink string) bool {
|
||||
if file.Link == brokenLink {
|
||||
file.Link = ""
|
||||
}
|
||||
return file.Link == brokenLink
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if existing.Added < toMerge.Added {
|
||||
mainTorrent.Added = toMerge.Added
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user