Updating torrent library to latest, fixing breaking changes to torrent library api
This commit is contained in:
@@ -32,8 +32,8 @@ func CreateServerPushMessage(message ServerPushMessage, conn *websocket.Conn) {
|
||||
conn.WriteJSON(message)
|
||||
}
|
||||
|
||||
func QueueJSONMessage(conn *websocket.Conn){
|
||||
|
||||
func QueueJSONMessage(conn *websocket.Conn) {
|
||||
|
||||
}
|
||||
|
||||
//RefreshSingleRSSFeed refreshing a single RSS feed to send to the client (so no updating database) mainly by updating the torrent list to display any changes
|
||||
@@ -332,8 +332,8 @@ func CreateRunningTorrentArray(tclient *torrent.Client, TorrentLocalArray []*Sto
|
||||
PercentDone := fmt.Sprintf("%.2f", float32(calculatedCompletedSize)/float32(calculatedTotalSize))
|
||||
fullClientDB.TorrentHash = TempHash
|
||||
fullClientDB.PercentDone = PercentDone
|
||||
fullClientDB.DataBytesRead = fullStruct.ConnStats.BytesReadData //used for calculations not passed to client calculating up/down speed
|
||||
fullClientDB.DataBytesWritten = fullStruct.ConnStats.BytesWrittenData //used for calculations not passed to client calculating up/down speed
|
||||
fullClientDB.DataBytesRead = fullStruct.ConnStats.BytesReadData.Int64() //used for calculations not passed to client calculating up/down speed
|
||||
fullClientDB.DataBytesWritten = fullStruct.ConnStats.BytesWrittenData.Int64() //used for calculations not passed to client calculating up/down speed
|
||||
fullClientDB.ActivePeers = activePeersString + " / (" + totalPeersString + ")"
|
||||
fullClientDB.TorrentHashString = TempHash.String()
|
||||
fullClientDB.TorrentName = singleTorrentFromStorage.TorrentName
|
||||
@@ -347,7 +347,7 @@ func CreateRunningTorrentArray(tclient *torrent.Client, TorrentLocalArray []*Sto
|
||||
TempHash := singleTorrent.InfoHash()
|
||||
if previousElement.TorrentHashString == TempHash.String() { //matching previous to new
|
||||
CalculateTorrentSpeed(singleTorrent, fullClientDB, previousElement, calculatedCompletedSize)
|
||||
fullClientDB.TotalUploadedBytes = singleTorrentFromStorage.UploadedBytes + (fullStruct.ConnStats.BytesWrittenData - previousElement.DataBytesWritten)
|
||||
fullClientDB.TotalUploadedBytes = singleTorrentFromStorage.UploadedBytes + (fullStruct.ConnStats.BytesWrittenData.Int64() - previousElement.DataBytesWritten)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -109,7 +109,7 @@ func CalculateTorrentSpeed(t *torrent.Torrent, c *ClientDB, oc ClientDB, complet
|
||||
dt := float32(now.Sub(oc.UpdatedAt)) // get the delta time length between now and last updated
|
||||
db := float32(bytes - oc.BytesCompleted) //getting the delta bytes
|
||||
rate := db * (float32(time.Second) / dt) // converting into seconds
|
||||
dbU := float32(bytesUpload - oc.DataBytesWritten)
|
||||
dbU := float32(bytesUpload.Int64() - oc.DataBytesWritten)
|
||||
rateUpload := dbU * (float32(time.Second) / dt)
|
||||
if rate >= 0 {
|
||||
rateMB := rate / 1024 / 1024 //creating MB to calculate ETA
|
||||
@@ -331,6 +331,27 @@ func ValidateQueues(db *storm.DB, config Settings.FullClientSettings, tclient *t
|
||||
}
|
||||
}
|
||||
}
|
||||
torrentQueues = Storage.FetchQueues(db)
|
||||
for _, singleTorrent := range tclient.Torrents() { //If we have a queued torrent that is missing data, and an active torrent that is seeding, then prioritize the missing data one
|
||||
for _, queuedTorrent := range torrentQueues.QueuedTorrents {
|
||||
if singleTorrent.InfoHash().String() == queuedTorrent {
|
||||
if singleTorrent.BytesMissing() > 0 {
|
||||
for _, activeTorrent := range torrentQueues.ActiveTorrents {
|
||||
for _, singleActiveTorrent := range tclient.Torrents() {
|
||||
if activeTorrent == singleActiveTorrent.InfoHash().String() {
|
||||
if singleActiveTorrent.Seeding() == true {
|
||||
singleTorrentFromStorage := Storage.FetchTorrentFromStorage(db, activeTorrent)
|
||||
RemoveTorrentFromActive(&singleTorrentFromStorage, singleActiveTorrent, db)
|
||||
singleTorrentFromStorage = Storage.FetchTorrentFromStorage(db, queuedTorrent)
|
||||
AddTorrentToActive(&singleTorrentFromStorage, singleTorrent, db)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//CalculateTorrentStatus is used to determine what the STATUS column of the frontend will display ll2
|
||||
|
Reference in New Issue
Block a user