Don't update Length if it hasn't changed
Cette révision appartient à :
Parent
7d8cbe1393
révision
58869114d7
1 fichiers modifiés avec 19 ajouts et 12 suppressions
|
@ -124,22 +124,29 @@ func (fetcher *MetainfoFetcher) gotResult(r Result) {
|
||||||
} else if r.info.TotalLength() == 0 {
|
} else if r.info.TotalLength() == 0 {
|
||||||
log.Infof("Got length 0 for torrent TID: %d. Possible bug?", r.operation.torrent.ID)
|
log.Infof("Got length 0 for torrent TID: %d. Possible bug?", r.operation.torrent.ID)
|
||||||
} else {
|
} else {
|
||||||
|
lengthOK := true
|
||||||
|
|
||||||
|
if r.operation.torrent.Filesize != r.info.TotalLength() {
|
||||||
log.Infof("Got length %d for torrent TID: %d. Updating.", r.info.TotalLength(), r.operation.torrent.ID)
|
log.Infof("Got length %d for torrent TID: %d. Updating.", r.info.TotalLength(), r.operation.torrent.ID)
|
||||||
r.operation.torrent.Filesize = r.info.TotalLength()
|
r.operation.torrent.Filesize = r.info.TotalLength()
|
||||||
_, err := torrentService.UpdateTorrent(r.operation.torrent)
|
_, err := torrentService.UpdateTorrent(r.operation.torrent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Infof("Failed to update torrent TID: %d with new filesize", r.operation.torrent.ID)
|
log.Infof("Failed to update torrent TID: %d with new filesize", r.operation.torrent.ID)
|
||||||
} else {
|
lengthOK = false
|
||||||
updatedSuccessfully = true
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filelistOK := true
|
||||||
// Create the file list, if it's missing.
|
// Create the file list, if it's missing.
|
||||||
if len(r.operation.torrent.FileList) == 0 {
|
if len(r.operation.torrent.FileList) == 0 {
|
||||||
err = updateFileList(r.operation.torrent, r.info)
|
err := updateFileList(r.operation.torrent, r.info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Infof("Failed to update file list of TID %d", r.operation.torrent.ID)
|
log.Infof("Failed to update file list of TID %d", r.operation.torrent.ID)
|
||||||
|
filelistOK = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatedSuccessfully = lengthOK && filelistOK
|
||||||
}
|
}
|
||||||
|
|
||||||
if !updatedSuccessfully {
|
if !updatedSuccessfully {
|
||||||
|
|
Référencer dans un nouveau ticket