Merge branch 'fuse-email-issue'

This commit is contained in:
Matt Joiner 2021-02-22 10:05:32 +11:00
commit 4bb2233b46
4 changed files with 22 additions and 15 deletions

View File

@ -51,7 +51,7 @@ jobs:
- run: go test -bench . ./...
- run: set +e; CGO_ENABLED=0 go test -v ./...; true
- run: GOARCH=386 go test ./... -count 2 -bench . || true
- run: go install ./cmd/torrentfs
- run: go install github.com/anacrolix/godo@latest
- save_cache:
key: go-pkg-{{ checksum "go.mod" }}
paths:

View File

@ -3,6 +3,7 @@ package torrentfs
import (
"context"
"io"
"log"
"bazil.org/fuse"
"bazil.org/fuse/fs"
@ -26,7 +27,8 @@ func (me fileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse
if req.Dir {
panic("read on directory")
}
pos, err := me.r.Seek(req.Offset, io.SeekStart)
r := me.r
pos, err := r.Seek(req.Offset, io.SeekStart)
if err != nil {
panic(err)
}
@ -44,10 +46,15 @@ func (me fileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse
me.fn.FS.event.Broadcast()
me.fn.FS.mu.Unlock()
var n int
r := missinggo.ContextedReader{me.r, ctx}
n, readErr = r.Read(resp.Data)
if readErr == io.EOF {
readErr = nil
r := missinggo.ContextedReader{r, ctx}
log.Printf("reading %v bytes at %v", len(resp.Data), req.Offset)
if true {
n, readErr = io.ReadFull(r, resp.Data)
} else {
n, readErr = r.Read(resp.Data)
if readErr == io.EOF {
readErr = nil
}
}
resp.Data = resp.Data[:n]
}()

View File

@ -1,17 +1,17 @@
set -ex
repopath=$(cd $(dirname $0)/..; pwd)
d=$(mktemp -d)
pushd "$d"
mkdir mnt torrents
GOPPROF=http torrentfs -mountDir=mnt -metainfoDir=torrents &
trap 'set +e; sudo umount -f mnt; pushd; rm -rv "$d"' EXIT
set -eux
repopath="$(cd "$(dirname "$0")/.."; pwd)"
mkdir -p mnt torrents
GOPPROF=http godo -v "$repopath/cmd/torrentfs" -mountDir=mnt -metainfoDir=torrents &> log &
trap 'set +e; sudo umount -f mnt' EXIT
debian_file=debian-10.8.0-amd64-netinst.iso
pushd torrents
cp "$repopath"/testdata/debian-9.1.0-amd64-netinst.iso.torrent .
cp "$repopath/testdata/$debian_file.torrent" .
echo 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4' > sintel.magnet
popd
file=debian-9.1.0-amd64-netinst.iso
file="$debian_file"
# file=sintel.mp4
while [ ! -e "mnt/$file" ]; do sleep 1; done
pv "mnt/$file" | md5sum
# expect e221f43f4fdd409250908fc4305727d4
sudo umount mnt
wait || echo "wait returned" $?

Binary file not shown.