mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-22 21:04:07 +08:00
fix(s3): unable to copy empty folder (close #4620)
This commit is contained in:
parent
3529023bf9
commit
61101a60f4
@ -53,9 +53,9 @@ func (d *S3) Drop(ctx context.Context) error {
|
||||
|
||||
func (d *S3) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
|
||||
if d.ListObjectVersion == "v2" {
|
||||
return d.listV2(dir.GetPath())
|
||||
return d.listV2(dir.GetPath(), args)
|
||||
}
|
||||
return d.listV1(dir.GetPath())
|
||||
return d.listV1(dir.GetPath(), args)
|
||||
}
|
||||
|
||||
func (d *S3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
||||
|
@ -69,7 +69,7 @@ func getPlaceholderName(placeholder string) string {
|
||||
return placeholder
|
||||
}
|
||||
|
||||
func (d *S3) listV1(prefix string) ([]model.Obj, error) {
|
||||
func (d *S3) listV1(prefix string, args model.ListArgs) ([]model.Obj, error) {
|
||||
prefix = getKey(prefix, true)
|
||||
log.Debugf("list: %s", prefix)
|
||||
files := make([]model.Obj, 0)
|
||||
@ -97,7 +97,7 @@ func (d *S3) listV1(prefix string) ([]model.Obj, error) {
|
||||
}
|
||||
for _, object := range listObjectsResult.Contents {
|
||||
name := path.Base(*object.Key)
|
||||
if name == getPlaceholderName(d.Placeholder) || name == d.Placeholder {
|
||||
if !args.S3ShowPlaceholder && (name == getPlaceholderName(d.Placeholder) || name == d.Placeholder) {
|
||||
continue
|
||||
}
|
||||
file := model.Object{
|
||||
@ -120,7 +120,7 @@ func (d *S3) listV1(prefix string) ([]model.Obj, error) {
|
||||
return files, nil
|
||||
}
|
||||
|
||||
func (d *S3) listV2(prefix string) ([]model.Obj, error) {
|
||||
func (d *S3) listV2(prefix string, args model.ListArgs) ([]model.Obj, error) {
|
||||
prefix = getKey(prefix, true)
|
||||
files := make([]model.Obj, 0)
|
||||
var continuationToken, startAfter *string
|
||||
@ -152,7 +152,7 @@ func (d *S3) listV2(prefix string) ([]model.Obj, error) {
|
||||
continue
|
||||
}
|
||||
name := path.Base(*object.Key)
|
||||
if name == getPlaceholderName(d.Placeholder) || name == d.Placeholder {
|
||||
if !args.S3ShowPlaceholder && (name == getPlaceholderName(d.Placeholder) || name == d.Placeholder) {
|
||||
continue
|
||||
}
|
||||
file := model.Object{
|
||||
@ -198,7 +198,7 @@ func (d *S3) copyFile(ctx context.Context, src string, dst string) error {
|
||||
}
|
||||
|
||||
func (d *S3) copyDir(ctx context.Context, src string, dst string) error {
|
||||
objs, err := op.List(ctx, d, src, model.ListArgs{})
|
||||
objs, err := op.List(ctx, d, src, model.ListArgs{S3ShowPlaceholder: true})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ import (
|
||||
)
|
||||
|
||||
type ListArgs struct {
|
||||
ReqPath string
|
||||
ReqPath string
|
||||
S3ShowPlaceholder bool
|
||||
}
|
||||
|
||||
type LinkArgs struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user