]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix crashes in torrentfs.fileNode.Read
authorMatt Joiner <anacrolix@gmail.com>
Wed, 27 Aug 2014 22:09:41 +0000 (08:09 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 27 Aug 2014 22:09:41 +0000 (08:09 +1000)
fs/torrentfs.go

index 3d712a19266e8cc590c9b926eca1e25a04c032cd..a8d18cf1fd72cee50f8da4e2a4d4f948eef94ba8 100644 (file)
@@ -87,6 +87,9 @@ func (fn fileNode) Read(req *fuse.ReadRequest, resp *fuse.ReadResponse, intr fus
        }()
        size := req.Size
        fileLeft := int64(fn.size) - req.Offset
+       if fileLeft < 0 {
+               fileLeft = 0
+       }
        if fileLeft < int64(size) {
                size = int(fileLeft)
        }
@@ -98,7 +101,7 @@ func (fn fileNode) Read(req *fuse.ReadRequest, resp *fuse.ReadResponse, intr fus
        torrentOff := fn.TorrentOffset + req.Offset
        go func() {
                if err := fn.FS.Client.PrioritizeDataRegion(infoHash, torrentOff, int64(size)); err != nil {
-                       panic(err)
+                       log.Printf("error prioritizing %s: %s", fn.fsPath(), err)
                }
        }()
        delayed := false