Skip to content

Commit

Permalink
Getting object
Browse files Browse the repository at this point in the history
  • Loading branch information
JarcauCristian committed Apr 21, 2024
1 parent 925d07c commit ef8095f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
26 changes: 6 additions & 20 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (minioInstance *MinIO) listPath(path string) ([]string, error) {
return files, nil
}

func (minioInstance *MinIO) findObject(datasetPath string, forever bool) (string, error) {
func (minioInstance *MinIO) findObject(datasetPath string) (string, error) {
healthyInstances, err := minioInstance.Healths()

if err != nil {
Expand All @@ -253,12 +253,7 @@ func (minioInstance *MinIO) findObject(datasetPath string, forever bool) (string

go func(alias []string, datasetPath string) {
defer wg.Done()

finding, err := search(alias, datasetPath)

if err != nil {
fmt.Println("Is not present here!")
}
finding, _ := search(alias, datasetPath)

if finding != "" {
findDataset = finding
Expand All @@ -268,14 +263,13 @@ func (minioInstance *MinIO) findObject(datasetPath string, forever bool) (string

wg.Wait()

shareUrl, err := minioInstance.getObject(findDataset, datasetPath, forever)
shareUrl, err := minioInstance.getObject(findDataset, datasetPath)

if err != nil {
fmt.Println(err)
return "", err
}

fmt.Println(err)

return shareUrl, nil
}

Expand Down Expand Up @@ -691,18 +685,10 @@ func (minioInstance *MinIO) getDirectObject(datasetPaths []string) (*minio.Objec
return reader, nil
}

func (minioInstance *MinIO) getObject(url string, datasetPath string, forever bool) (string, error) {
func (minioInstance *MinIO) getObject(url string, datasetPath string) (string, error) {
path := fmt.Sprintf("%s/%s", minioInstance.aliases[url], datasetPath)

var expirationTime string

if forever {
expirationTime = "7d"
} else {
expirationTime = "10m"
}

cmdArgs := []string{"./mc", "share", "download", "--expire", expirationTime, "--json", path}
cmdArgs := []string{"./mc", "share", "download", "--json", path}

cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
var stdout bytes.Buffer
Expand Down
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,15 @@ func main() {
} else {
foreverBool, _ := strconv.ParseBool(forever)

data, err := minio.findObject(datasetPath, foreverBool)
if foreverBool {
datasetPath = "dataspace/" + datasetPath
} else {
datasetPath = "temp/" + datasetPath
}

data, err := minio.findObject(datasetPath)

if err != nil {
fmt.Println(err)
c.JSON(500, gin.H{
"message": "Something went wrong when getting the object!",
})
Expand Down
Binary file modified mc.exe
Binary file not shown.

0 comments on commit ef8095f

Please sign in to comment.