saveTorrentChangesToDisk when relevant
This commit is contained in:
@@ -201,3 +201,18 @@ func (t *TorrentManager) initializeDirectories() {
|
||||
t.DirectoryMap.Set(directory, cmap.New[*Torrent]())
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TorrentManager) saveTorrentChangesToDisk(torrent *Torrent, cb func(*Torrent)) {
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
torrent.DownloadedIDs.Union(torrent.InProgressIDs).Each(func(id string) bool {
|
||||
info, exists := infoCache.Get(id)
|
||||
if !exists {
|
||||
return false
|
||||
}
|
||||
if cb != nil {
|
||||
cb(info)
|
||||
}
|
||||
t.writeTorrentToFile(id, info)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user