mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Fix filer.backup local sink to propagate file mode changes (#4896)
This commit is contained in:
parent
0fd7222d65
commit
082f67bfe9
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue