Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
fix wrong assumption to file start
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Aperis <[email protected]>
  • Loading branch information
blankdots and aaperis committed Jan 15, 2024
1 parent 81d7cc3 commit 511b5dc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .github/integration/tests/common/50_check_endpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,28 @@ fi

curl --cacert certs/ca.pem -H "Authorization: Bearer $token" "https://localhost:8443/files/urn:neic:001-002?startCoordinate=0&endCoordinate=2" --output test-part.txt

echo "TH" > old-part.txt
dd if=old-file.txt ibs=1 skip=0 count=2 > old-part.txt

cmp --silent old-part.txt test-part.txt
status=$?
if [[ $status = 0 ]]; then
echo "Files are the same"
else
echo "Files are different"
exit 1
fi

curl --cacert certs/ca.pem -H "Authorization: Bearer $token" "https://localhost:8443/files/urn:neic:001-002?startCoordinate=7&endCoordinate=14" --output test-part2.txt

echo "LE IS J" > old-part2.txt
dd if=old-file.txt ibs=1 skip=7 count=7 > old-part2.txt

cmp --silent old-part2.txt test-part2.txt
status=$?
if [[ $status = 0 ]]; then
echo "Files are the same"
else
echo "Files are different"
exit 1
fi

# ------------------
Expand Down
6 changes: 4 additions & 2 deletions .github/integration/tests/s3notls/52_check_endpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,28 @@ fi

curl -H "Authorization: Bearer $token" "http://localhost:8080/files/urn:neic:001-002?startCoordinate=0&endCoordinate=2" --output test-part.txt

echo "TH" > old-part.txt
dd if=old-file.txt ibs=1 skip=0 count=2 > old-part.txt

cmp --silent old-part.txt test-part.txt
status=$?
if [[ $status = 0 ]]; then
echo "Files are the same"
else
echo "Files are different"
exit 1
fi

curl -H "Authorization: Bearer $token" "http://localhost:8080/files/urn:neic:001-002?startCoordinate=7&endCoordinate=14" --output test-part2.txt

echo "LE IS J" > old-part2.txt
dd if=old-file.txt ibs=1 skip=7 count=7 > old-part2.txt

cmp --silent old-part2.txt test-part2.txt
status=$?
if [[ $status = 0 ]]; then
echo "Files are the same"
else
echo "Files are different"
exit 1
fi

# ------------------
Expand Down
7 changes: 7 additions & 0 deletions api/sda/sda.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ func Download(c *gin.Context) {
// used from: https://github.com/neicnordic/crypt4gh/blob/master/examples/reader/main.go#L48C1-L113C1
var sendStream = func(reader *streaming.Crypt4GHReader, writer http.ResponseWriter, start, end int64) error {

if start != 0 {
// We don't want to read from start, skip ahead to where we should be
if _, err := reader.Seek(start, 0); err != nil {
return err
}
}

// Calculate how much we should read (if given)
togo := end - start

Expand Down

0 comments on commit 511b5dc

Please sign in to comment.