Add triggers again
This commit is contained in:
@@ -35,7 +35,5 @@ func HandleDeleteFile(directory, torrentName, fileName string, torMgr *torrent.T
|
|||||||
if torMgr.CheckDeletedState(torrent) {
|
if torMgr.CheckDeletedState(torrent) {
|
||||||
torMgr.Delete(torrentName, true)
|
torMgr.Delete(torrentName, true)
|
||||||
}
|
}
|
||||||
// todo: triggeer an update ???
|
|
||||||
// t.TriggerHookOnLibraryUpdate(updatedPaths)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, p
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TorrentManager) RefreshTorrents() {
|
func (t *TorrentManager) RefreshTorrents() {
|
||||||
instances, _, err := t.Api.GetTorrents(10)
|
instances, _, err := t.Api.GetTorrents(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.log.Warnf("Cannot get torrents: %v\n", err)
|
t.log.Warnf("Cannot get torrents: %v\n", err)
|
||||||
return
|
return
|
||||||
@@ -154,6 +154,7 @@ func (t *TorrentManager) RefreshTorrents() {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
// new
|
// new
|
||||||
|
var updatedPaths []string
|
||||||
strset.Difference(freshKeys, t.accessKeySet).Each(func(accessKey string) bool {
|
strset.Difference(freshKeys, t.accessKeySet).Each(func(accessKey string) bool {
|
||||||
t.accessKeySet.Add(accessKey)
|
t.accessKeySet.Add(accessKey)
|
||||||
tor, _ := allTorrents.Get(accessKey)
|
tor, _ := allTorrents.Get(accessKey)
|
||||||
@@ -163,11 +164,14 @@ func (t *TorrentManager) RefreshTorrents() {
|
|||||||
}
|
}
|
||||||
torrents, _ := t.DirectoryMap.Get(directory)
|
torrents, _ := t.DirectoryMap.Get(directory)
|
||||||
torrents.Set(accessKey, tor)
|
torrents.Set(accessKey, tor)
|
||||||
|
updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, accessKey))
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
t.SetNewLatestState(t.getCurrentState())
|
t.SetNewLatestState(t.getCurrentState())
|
||||||
|
|
||||||
|
t.TriggerHookOnLibraryUpdate(updatedPaths)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getMoreInfo gets original name, size and files for a torrent
|
// getMoreInfo gets original name, size and files for a torrent
|
||||||
@@ -718,6 +722,12 @@ func (t *TorrentManager) Repair(torrent *Torrent) {
|
|||||||
t.repair(torrent)
|
t.repair(torrent)
|
||||||
t.log.Info("Finished repairing torrent %s", torrent.AccessKey)
|
t.log.Info("Finished repairing torrent %s", torrent.AccessKey)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var updatedPaths []string
|
||||||
|
t.AssignedDirectoryCb(torrent, func(directory string) {
|
||||||
|
updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, torrent.AccessKey))
|
||||||
|
})
|
||||||
|
t.TriggerHookOnLibraryUpdate(updatedPaths)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TorrentManager) AssignedDirectoryCb(tor *Torrent, cb func(string)) {
|
func (t *TorrentManager) AssignedDirectoryCb(tor *Torrent, cb func(string)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user