]> Sergey Matveev's repositories - btrtrc.git/blobdiff - storage/file-piece.go
Add cove to downstream projects
[btrtrc.git] / storage / file-piece.go
index 23cf4eecb540fcce5b32278c6e4835db2c30c3ac..47772017e3e1680f28a8e4de7bb74aa40202aa5f 100644 (file)
@@ -28,20 +28,25 @@ func (fs *filePieceImpl) Completion() Completion {
                c.Ok = false
                return c
        }
+
+       verified := true
        if c.Complete {
                // If it's allegedly complete, check that its constituent files have the necessary length.
                for _, fi := range extentCompleteRequiredLengths(fs.p.Info, fs.p.Offset(), fs.p.Length()) {
                        s, err := os.Stat(fs.files[fi.fileIndex].path)
                        if err != nil || s.Size() < fi.length {
-                               c.Complete = false
+                               verified = false
                                break
                        }
                }
        }
-       if !c.Complete {
+
+       if !verified {
                // The completion was wrong, fix it.
+               c.Complete = false
                fs.completion.Set(fs.pieceKey(), false)
        }
+
        return c
 }