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

Commit

Permalink
Update download to work with htsget
Browse files Browse the repository at this point in the history
  • Loading branch information
dbampalikis committed Feb 21, 2024
1 parent bf6828c commit 014c825
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion api/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ func ListObjects(c *gin.Context) {

func getFileInfo(c *gin.Context) (fileInfo *database.FileInfo, err error) {
// Get file info for the given file path (or abort)
fileInfo, err = database.GetDatasetFileInfo(c.Param("dataset"), c.Param("filename")+".c4gh")
filename := c.Param("filename")
if !strings.Contains(c.Param("filename"), "c4gh") {
filename = c.Param("filename") + ".c4gh"
}
fileInfo, err = database.GetDatasetFileInfo(c.Param("dataset"), filename)
if err != nil {
if err.Error() == "sql: no rows in result set" {
c.AbortWithStatus(http.StatusNotFound)
Expand Down
11 changes: 9 additions & 2 deletions api/sda/sda.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ func Download(c *gin.Context) {
c.Header("Content-Disposition", fmt.Sprintf("filename: %v", fileID))
c.Header("ETag", fileDetails.DecryptedChecksum)
c.Header("Last-Modified", lastModified.Format(http.TimeFormat))

// set the user and server public keys that is send from htsget
log.Debugf("Got to setting the headers: %s", c.GetHeader("client-public-key"))
c.Header("client-public-key", c.GetHeader("client-public-key"))
c.Header("private-public-key", c.GetHeader("private-public-key"))

}

if c.Request.Method == http.MethodHead {
Expand Down Expand Up @@ -357,7 +363,7 @@ var sendStream = func(reader io.Reader, writer http.ResponseWriter, start, end i
// it will be used as is. If not, the functions parameters will be used,
// and adjusted to match the data block boundaries of the encrypted file.
var calculateEncryptedCoords = func(start, end int64, htsget_range string, fileDetails *database.FileDownload) (int64, int64) {
if htsget_range != "" {
/* if htsget_range != "" {
startEnd := strings.Split(strings.TrimPrefix(htsget_range, "bytes="), "-")
if len(startEnd) > 1 {
a, errA := strconv.ParseInt(startEnd[0], 10, 64)
Expand All @@ -368,7 +374,8 @@ var calculateEncryptedCoords = func(start, end int64, htsget_range string, fileD
return a, b
}
}
}
} */
//log.Debugf("Range found: %d - %d", start, end)

Check failure on line 378 in api/sda/sda.go

View workflow job for this annotation

GitHub Actions / Check code (1.20)

commentFormatting: put a space between `//` and comment text (gocritic)
// Adapt end coordinate to follow the crypt4gh block boundaries
headlength := bytes.NewReader(fileDetails.Header)
bodyEnd := int64(fileDetails.ArchiveSize)
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func NewConfig() (*Map, error) {
}
}
requiredConfVars := []string{
"db.host", "db.user", "db.password", "db.database", "c4gh.filepath", "c4gh.passphrase", "oidc.configuration.url",
"db.host", "db.user", "db.password", "db.database", "c4gh.filepath", "oidc.configuration.url",
}

if viper.GetString("archive.type") == S3 {
Expand Down

0 comments on commit 014c825

Please sign in to comment.