-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug Fix: Fix the bug that will fail when the number of deleted object…
…s is greater than 1000
- Loading branch information
1 parent
0f23daa
commit 179519e
Showing
2 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package util | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/tencentyun/cos-go-sdk-v5" | ||
"os" | ||
) | ||
|
||
func GetObjectsListIterator(c *cos.Client, prefix, marker string, include, exclude string) (objects []cos.Object, isTruncated bool, nextMarker string) { | ||
opt := &cos.BucketGetOptions{ | ||
Prefix: prefix, | ||
Delimiter: "", | ||
EncodingType: "", | ||
Marker: marker, | ||
MaxKeys: 0, | ||
} | ||
|
||
|
||
res, _, err := c.Bucket.Get(context.Background(), opt) | ||
if err != nil { | ||
_, _ = fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
|
||
objects = append(objects, res.Contents...) | ||
isTruncated = res.IsTruncated | ||
nextMarker = res.NextMarker | ||
|
||
if len(include) > 0 { | ||
objects = MatchCosPattern(objects, include, true) | ||
} | ||
if len(exclude) > 0 { | ||
objects = MatchCosPattern(objects, exclude, false) | ||
} | ||
|
||
return objects, isTruncated, nextMarker | ||
} |