From 69184daa7725dd6cdb460f890832628dcb8d24fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Duy=20Ho=C3=A0ng=20V=C5=A9?= Date: Sat, 14 Mar 2020 12:41:21 +0700 Subject: [PATCH] task done when files done and exclude the stopped file --- engine/torrent.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/torrent.go b/engine/torrent.go index 7836d380e..37bd347cd 100644 --- a/engine/torrent.go +++ b/engine/torrent.go @@ -68,6 +68,7 @@ func (torrent *Torrent) updateLoaded(t *torrent.Torrent) { if len(tfiles) > 0 && torrent.Files == nil { torrent.Files = make([]*File, len(tfiles)) } + torrent.Done = true //merge in files for i, f := range tfiles { path := f.Path() @@ -82,6 +83,7 @@ func (torrent *Torrent) updateLoaded(t *torrent.Torrent) { file.Percent = percent(file.Completed, file.Size) file.Done = (file.Completed == file.Size) file.f = f + torrent.Done = torrent.Done && (file.Done || !file.Started) } torrent.Stats = t.Stats() @@ -105,7 +107,7 @@ func (torrent *Torrent) updateLoaded(t *torrent.Torrent) { torrent.updatedAt = now torrent.Percent = percent(bytes, torrent.Size) - torrent.Done = t.BytesMissing() == 0 + //torrent.Done = t.BytesMissing() == 0 // calculate ratio bRead := torrent.Stats.BytesReadData.Int64()