Browse Source
Fix filer.backup local sink to propagate file mode changes (#4896)
pull/4898/head
Andrew Garrett
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
13 additions and
1 deletions
-
weed/replication/sink/localsink/local_sink.go
|
@ -90,12 +90,24 @@ func (localsink *LocalSink) CreateEntry(key string, entry *filer_pb.Entry, signa |
|
|
return os.Mkdir(key, os.FileMode(entry.Attributes.FileMode)) |
|
|
return os.Mkdir(key, os.FileMode(entry.Attributes.FileMode)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
dstFile, err := os.OpenFile(util.ToShortFileName(key), os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.FileMode(entry.Attributes.FileMode)) |
|
|
|
|
|
|
|
|
mode := os.FileMode(entry.Attributes.FileMode) |
|
|
|
|
|
dstFile, err := os.OpenFile(util.ToShortFileName(key), os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
defer dstFile.Close() |
|
|
defer dstFile.Close() |
|
|
|
|
|
|
|
|
|
|
|
fi, err := dstFile.Stat() |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
if fi.Mode() != mode { |
|
|
|
|
|
glog.V(4).Infof("Modify file mode: %o -> %o", fi.Mode(), mode) |
|
|
|
|
|
if err := dstFile.Chmod(mode); err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
writeFunc := func(data []byte) error { |
|
|
writeFunc := func(data []byte) error { |
|
|
_, writeErr := dstFile.Write(data) |
|
|
_, writeErr := dstFile.Write(data) |
|
|
return writeErr |
|
|
return writeErr |
|
|