3 . "$(dirname "$0")/testlib.sh"
5 begin_test "resume-http-range"
9 reponame="$(basename "$0" ".sh")"
10 setup_remote_repo "$reponame"
12 clone_repo "$reponame" $reponame
14 git lfs track "*.dat" 2>&1 | tee track.log
15 grep "Tracking \"\*.dat\"" track.log
17 # this string announces to server that we want a test that
18 # interrupts the transfer when started from 0 to cause resume
19 contents="status-batch-resume-206"
20 contents_oid=$(calc_oid "$contents")
22 printf "$contents" > a.dat
24 git add .gitattributes
25 git commit -m "add a.dat" 2>&1 | tee commit.log
26 git push origin master
28 assert_server_object "$reponame" "$contents_oid"
30 # delete local copy then fetch it back
31 # server will abort the transfer mid way (so will error) when not resuming
32 # then we can restart it
33 rm -rf .git/lfs/objects
34 git lfs fetch 2>&1 | tee fetchinterrupted.log
35 refute_local_object "$contents_oid"
37 # now fetch again, this should try to resume and server should send remainder
38 # this time (it does not cut short when Range is requested)
39 GIT_TRACE=1 git lfs fetch 2>&1 | tee fetchresume.log
40 grep "xfer: server accepted resume" fetchresume.log
41 assert_local_object "$contents_oid" "${#contents}"
46 begin_test "resume-http-range-fallback"
50 reponame="resume-http-range-fallback"
51 setup_remote_repo "$reponame"
53 clone_repo "$reponame" $reponame
55 git lfs track "*.dat" 2>&1 | tee track.log
56 grep "Tracking \"\*.dat\"" track.log
58 # this string announces to server that we want it to abort the download part
59 # way, but reject the Range: header and fall back on re-downloading instead
60 contents="batch-resume-fail-fallback"
61 contents_oid=$(calc_oid "$contents")
63 printf "$contents" > a.dat
65 git add .gitattributes
66 git commit -m "add a.dat" 2>&1 | tee commit.log
67 git push origin master
69 assert_server_object "$reponame" "$contents_oid"
71 # delete local copy then fetch it back
72 # server will abort the transfer mid way (so will error) when not resuming
73 # then we can restart it
74 rm -rf .git/lfs/objects
75 git lfs fetch 2>&1 | tee fetchinterrupted.log
76 refute_local_object "$contents_oid"
78 # now fetch again, this should try to resume but server should reject the Range
79 # header, which should cause client to re-download
80 GIT_TRACE=1 git lfs fetch 2>&1 | tee fetchresumefallback.log
81 grep "xfer: server rejected resume" fetchresumefallback.log
82 # re-download should still have worked
83 assert_local_object "$contents_oid" "${#contents}"