Add library update hook on repair all

This commit is contained in:
Ben Sarmiento
2023-12-07 15:58:22 +01:00
parent 10aac20030
commit 845a01d7f3
5 changed files with 18 additions and 10 deletions

View File

@@ -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
})