Add basic auth and fix repair issues

This commit is contained in:
Ben Sarmiento
2024-01-09 16:53:12 +01:00
parent eb3f2785ce
commit 91f6d35831
7 changed files with 73 additions and 39 deletions

View File

@@ -133,11 +133,11 @@ func (t *TorrentManager) repair(torrent *Torrent) {
if t.reinsertTorrent(torrent, "") {
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
return
} else if !torrent.Unfixable {
t.log.Warnf("Failed to repair by reinserting torrent %s, will only redownload broken files...", torrent.AccessKey)
} else {
} else if torrent.Unfixable {
t.log.Warnf("Cannot repair torrent %s", torrent.AccessKey)
return
} else {
t.log.Warnf("Failed to repair by reinserting torrent %s, will only redownload broken files...", torrent.AccessKey)
}
} else {
t.log.Warnf("Torrent %s is not older than %d hours to be repaired by reinsertion, will only redownload broken files...", torrent.AccessKey, EXPIRED_LINK_TOLERANCE_HOURS)
@@ -210,9 +210,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
})
t.log.Debugf("During repair, zurg found %d broken files for torrent %s", len(brokenFiles), torrent.AccessKey)
// todo: to verify removed logic when there's only 1 selected file selected and it's broken
if len(brokenFiles) == 1 && torrent.SelectedFiles.Count() > 1 {
if len(brokenFiles) == 1 && torrent.SelectedFiles.Count() > 2 {
// if we download a single file, it will be named differently
// so we need to download 1 extra file to preserve the name
// this is only relevant if we enable retain_rd_torrent_name
@@ -227,7 +225,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
}
if len(brokenFiles) > 0 {
t.log.Infof("Redownloading the %d broken files for torrent %s", len(brokenFiles), torrent.AccessKey)
t.log.Infof("Redownloading %dof%d files for torrent %s", len(brokenFiles), torrent.SelectedFiles.Count(), torrent.AccessKey)
brokenFileIDs := strings.Join(getFileIDs(brokenFiles), ",")
if t.reinsertTorrent(torrent, brokenFileIDs) {
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)