Add library update hook on repair all
This commit is contained in:
@@ -26,7 +26,7 @@ func (t *TorrentManager) Delete(accessKey string, deleteInRD bool) {
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
if torrent, ok := allTorrents.Get(accessKey); ok {
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
t.log.Infof("Deleting torrent %s %s in RD", id, accessKey)
|
||||
t.log.Debugf("Deleting torrent %s %s in RD", id, accessKey)
|
||||
t.Api.DeleteTorrent(id)
|
||||
infoCache.Remove(id)
|
||||
t.deleteTorrentFile(id)
|
||||
|
||||
@@ -43,6 +43,6 @@ func OnLibraryUpdateHook(paths []string, config config.ConfigInterface, log *log
|
||||
return
|
||||
}
|
||||
if output != "" {
|
||||
log.Infof("Output of hook on_library_update:\n%s", output)
|
||||
log.Debugf("Output of hook on_library_update:\n%s", output)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
}
|
||||
wg.Wait()
|
||||
close(infoChan)
|
||||
t.log.Infof("Fetched info for %d torrents", len(instances))
|
||||
t.log.Debugf("Fetched info for %d torrents", len(instances))
|
||||
|
||||
freshKeys := set.NewStringSet()
|
||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||
@@ -55,6 +55,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
strset.Difference(freshKeys, t.allAccessKeys).Each(func(accessKey string) bool {
|
||||
// assign to directories
|
||||
tor, _ := allTorrents.Get(accessKey)
|
||||
var directories []string
|
||||
t.assignedDirectoryCb(tor, func(directory string) {
|
||||
if strings.HasPrefix(directory, "int__") {
|
||||
return
|
||||
@@ -62,8 +63,11 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
torrents, _ := t.DirectoryMap.Get(directory)
|
||||
torrents.Set(accessKey, tor)
|
||||
updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, accessKey))
|
||||
if directory != "__all__" {
|
||||
directories = append(directories, directory)
|
||||
}
|
||||
})
|
||||
t.log.Infof("Added %s to the library", accessKey)
|
||||
t.log.Debugf("Added %s to %v", accessKey, directories)
|
||||
t.allAccessKeys.Add(accessKey)
|
||||
return true
|
||||
})
|
||||
|
||||
@@ -9,9 +9,8 @@ import (
|
||||
|
||||
func (t *TorrentManager) RepairAll() {
|
||||
_ = t.repairWorker.Submit(func() {
|
||||
t.log.Info("Checking for torrents to repair")
|
||||
t.repairAll()
|
||||
t.log.Info("Finished checking for torrents to repair")
|
||||
t.log.Debug("Finished repairing all torrents")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -27,10 +26,16 @@ func (t *TorrentManager) repairAll() {
|
||||
}
|
||||
})
|
||||
t.log.Debugf("Found %d torrents to repair", len(toRepair))
|
||||
var updatedPaths []string
|
||||
for i := range toRepair {
|
||||
t.log.Infof("Repairing %s", toRepair[i].AccessKey)
|
||||
t.repair(toRepair[i])
|
||||
torrent := toRepair[i]
|
||||
t.log.Infof("Repairing %s", torrent.AccessKey)
|
||||
t.repair(torrent)
|
||||
t.assignedDirectoryCb(torrent, func(directory string) {
|
||||
updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, torrent.AccessKey))
|
||||
})
|
||||
}
|
||||
t.TriggerHookOnLibraryUpdate(updatedPaths)
|
||||
}
|
||||
|
||||
func (t *TorrentManager) Repair(torrent *Torrent) {
|
||||
@@ -205,7 +210,6 @@ func (t *TorrentManager) canCapacityHandle() bool {
|
||||
}
|
||||
|
||||
if count.DownloadingCount < count.MaxNumberOfTorrents {
|
||||
// t.log.Infof("We can still add a new torrent, we have capacity for %d more", count.MaxNumberOfTorrents-count.DownloadingCount)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user