share: Download shares the url of exact prefix (#2096)
When recursive flag is not specified, share download will only generate download urls for the object which has the exact same prefix.
This commit is contained in:
committed by
Harshavardhana
parent
3b57e86cd3
commit
923c0e24b1
@@ -116,7 +116,32 @@ func doShareDownloadURL(targetURL string, isRecursive bool, expiry time.Duration
|
||||
|
||||
// Generate share URL for each target.
|
||||
isIncomplete := false
|
||||
for content := range clnt.List(isRecursive, isIncomplete, DirNone) {
|
||||
|
||||
// Channel which will receive objects whose URLs need to be shared
|
||||
objectsCh := make(chan *clientContent)
|
||||
|
||||
if !isRecursive {
|
||||
// Share thr url of only one exact prefix if it exists
|
||||
content, err := clnt.Stat(isIncomplete)
|
||||
if err != nil {
|
||||
return err.Trace(clnt.GetURL().String())
|
||||
}
|
||||
go func() {
|
||||
defer close(objectsCh)
|
||||
objectsCh <- content
|
||||
}()
|
||||
} else {
|
||||
// Recursive mode: Share list of objects
|
||||
go func() {
|
||||
defer close(objectsCh)
|
||||
for content := range clnt.List(isRecursive, isIncomplete, DirNone) {
|
||||
objectsCh <- content
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Iterate over all objects to generate share URL
|
||||
for content := range objectsCh {
|
||||
if content.Err != nil {
|
||||
return content.Err.Trace(clnt.GetURL().String())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user