Much more stringent check
This commit is contained in:
@@ -32,7 +32,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
|||||||
torrent, _ := t.onlyForRepair.Get(instances[idx].ID)
|
torrent, _ := t.onlyForRepair.Get(instances[idx].ID)
|
||||||
brokenFiles := getBrokenFiles(torrent)
|
brokenFiles := getBrokenFiles(torrent)
|
||||||
info, err := t.redownloadTorrent(torrent, "")
|
info, err := t.redownloadTorrent(torrent, "")
|
||||||
if err == nil && info.Progress == 100 && !t.isStillBroken(info, brokenFiles) {
|
if err == nil && info.IsDone() && !t.isStillBroken(info, brokenFiles) {
|
||||||
t.Api.DeleteTorrent(instances[idx].ID)
|
t.Api.DeleteTorrent(instances[idx].ID)
|
||||||
t.onlyForRepair.Remove(instances[idx].ID)
|
t.onlyForRepair.Remove(instances[idx].ID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
|||||||
info, err := t.redownloadTorrent(torrent, "")
|
info, err := t.redownloadTorrent(torrent, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.log.Warnf("Cannot repair torrent %s", t.GetKey(torrent))
|
t.log.Warnf("Cannot repair torrent %s", t.GetKey(torrent))
|
||||||
} else if info.Progress != 100 || (info.Progress == 100 && !t.isStillBroken(info, brokenFiles)) {
|
} else if info.Progress != 100 || (info.IsDone() && !t.isStillBroken(info, brokenFiles)) {
|
||||||
t.log.Infof("Successfully repaired torrent %s using repair_method#1", t.GetKey(torrent))
|
t.log.Infof("Successfully repaired torrent %s using repair_method#1", t.GetKey(torrent))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ type TorrentInfo struct {
|
|||||||
Files []File `json:"files"`
|
Files []File `json:"files"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *TorrentInfo) IsDone() bool {
|
||||||
|
if i.Progress != 100 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return len(i.Files) == len(i.Links) && len(i.Files) > 0
|
||||||
|
}
|
||||||
|
|
||||||
func (i *TorrentInfo) MarshalJSON() ([]byte, error) {
|
func (i *TorrentInfo) MarshalJSON() ([]byte, error) {
|
||||||
type Alias TorrentInfo
|
type Alias TorrentInfo
|
||||||
aux := &struct {
|
aux := &struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user