file metadata
This commit is contained in:
@@ -32,14 +32,43 @@ func (t *TorrentManager) refreshTorrents() {
|
||||
}
|
||||
t.checksum = checksum
|
||||
t.cache.Purge()
|
||||
t.torrents = t.getAll()
|
||||
for _, torrent := range t.torrents {
|
||||
go func(id string) {
|
||||
t.workerPool <- true
|
||||
t.getInfo(id)
|
||||
<-t.workerPool
|
||||
time.Sleep(1 * time.Second) // sleep for 1 second to avoid rate limiting
|
||||
}(torrent.ID)
|
||||
|
||||
newTorrents := t.getAll()
|
||||
|
||||
// Identify removed torrents
|
||||
for i := 0; i < len(t.torrents); i++ {
|
||||
found := false
|
||||
for _, newTorrent := range newTorrents {
|
||||
if t.torrents[i].ID == newTorrent.ID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
// Remove this torrent from the slice
|
||||
t.torrents = append(t.torrents[:i], t.torrents[i+1:]...)
|
||||
i-- // Decrement index since we modified the slice
|
||||
}
|
||||
}
|
||||
|
||||
// Identify and handle added torrents
|
||||
for _, newTorrent := range newTorrents {
|
||||
found := false
|
||||
for _, torrent := range t.torrents {
|
||||
if newTorrent.ID == torrent.ID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.torrents = append(t.torrents, newTorrent)
|
||||
go func(id string) {
|
||||
t.workerPool <- true
|
||||
t.getInfo(id)
|
||||
<-t.workerPool
|
||||
time.Sleep(1 * time.Second) // sleep for 1 second to avoid rate limiting
|
||||
}(newTorrent.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,6 +222,7 @@ func (t *TorrentManager) getInfo(torrentID string) *Torrent {
|
||||
// TODO: This means some files have expired
|
||||
// we need to 'fix' this torrent then, at least the missing selected files
|
||||
log.Println("Some links has expired for", info.Name)
|
||||
|
||||
type Result struct {
|
||||
Response *realdebrid.UnrestrictResponse
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user