diff --git a/api/s3/s3.go b/api/s3/s3.go index 947ef13..ec34d95 100644 --- a/api/s3/s3.go +++ b/api/s3/s3.go @@ -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) diff --git a/api/sda/sda.go b/api/sda/sda.go index 70cf961..1575d7a 100644 --- a/api/sda/sda.go +++ b/api/sda/sda.go @@ -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 { @@ -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) @@ -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) // Adapt end coordinate to follow the crypt4gh block boundaries headlength := bytes.NewReader(fileDetails.Header) bodyEnd := int64(fileDetails.ArchiveSize) diff --git a/internal/config/config.go b/internal/config/config.go index debbb9a..0421df1 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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 {