Skip to content

Commit

Permalink
cmd/sync: fix the bug where empty files are always synchronized (#4223)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored Dec 4, 2023
1 parent 541386f commit 1a82b80
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/object/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,11 @@ func (p *withPrefix) ListUploads(marker string) ([]*PendingPart, string, error)
}

var _ ObjectStorage = &withPrefix{}

func IsFileSystem(object ObjectStorage) bool {
if o, ok := object.(*withPrefix); ok {
object = o.os
}
_, ok := object.(FileSystem)
return ok
}
8 changes: 8 additions & 0 deletions pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,14 @@ SINGLE:
var in io.ReadCloser
var err error
if size == 0 {
if object.IsFileSystem(src) {
// for check permissions
r, err := src.Get(key, 0, -1)
if err != nil {
return err
}
_ = r.Close()
}
in = io.NopCloser(bytes.NewReader(nil))
} else {
in, err = src.Get(key, 0, size)
Expand Down

0 comments on commit 1a82b80

Please sign in to comment.