|
@@ -448,17 +448,28 @@ func (c *BaseConnection) DoStat(fsPath string, mode int) (os.FileInfo, error) {
|
|
|
return c.Fs.Stat(c.getRealFsPath(fsPath))
|
|
|
}
|
|
|
|
|
|
-// SetStat set StatAttributes for the specified fsPath
|
|
|
-func (c *BaseConnection) SetStat(fsPath, virtualPath string, attributes *StatAttributes) error {
|
|
|
+func (c *BaseConnection) ignoreSetStat() bool {
|
|
|
if Config.SetstatMode == 1 {
|
|
|
- return nil
|
|
|
+ return true
|
|
|
}
|
|
|
+ if Config.SetstatMode == 2 && !vfs.IsLocalOsFs(c.Fs) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+// SetStat set StatAttributes for the specified fsPath
|
|
|
+// nolint:gocyclo
|
|
|
+func (c *BaseConnection) SetStat(fsPath, virtualPath string, attributes *StatAttributes) error {
|
|
|
pathForPerms := c.getPathForSetStatPerms(fsPath, virtualPath)
|
|
|
|
|
|
if attributes.Flags&StatAttrPerms != 0 {
|
|
|
if !c.User.HasPerm(dataprovider.PermChmod, pathForPerms) {
|
|
|
return c.GetPermissionDeniedError()
|
|
|
}
|
|
|
+ if c.ignoreSetStat() {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
if err := c.Fs.Chmod(c.getRealFsPath(fsPath), attributes.Mode); err != nil {
|
|
|
c.Log(logger.LevelWarn, "failed to chmod path %#v, mode: %v, err: %+v", fsPath, attributes.Mode.String(), err)
|
|
|
return c.GetFsError(err)
|
|
@@ -471,6 +482,9 @@ func (c *BaseConnection) SetStat(fsPath, virtualPath string, attributes *StatAtt
|
|
|
if !c.User.HasPerm(dataprovider.PermChown, pathForPerms) {
|
|
|
return c.GetPermissionDeniedError()
|
|
|
}
|
|
|
+ if c.ignoreSetStat() {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
if err := c.Fs.Chown(c.getRealFsPath(fsPath), attributes.UID, attributes.GID); err != nil {
|
|
|
c.Log(logger.LevelWarn, "failed to chown path %#v, uid: %v, gid: %v, err: %+v", fsPath, attributes.UID,
|
|
|
attributes.GID, err)
|
|
@@ -484,7 +498,9 @@ func (c *BaseConnection) SetStat(fsPath, virtualPath string, attributes *StatAtt
|
|
|
if !c.User.HasPerm(dataprovider.PermChtimes, pathForPerms) {
|
|
|
return c.GetPermissionDeniedError()
|
|
|
}
|
|
|
-
|
|
|
+ if c.ignoreSetStat() {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
if err := c.Fs.Chtimes(c.getRealFsPath(fsPath), attributes.Atime, attributes.Mtime); err != nil {
|
|
|
c.Log(logger.LevelWarn, "failed to chtimes for path %#v, access time: %v, modification time: %v, err: %+v",
|
|
|
fsPath, attributes.Atime, attributes.Mtime, err)
|
|
@@ -950,6 +966,8 @@ func (c *BaseConnection) GetFsError(err error) error {
|
|
|
return c.GetNotExistError()
|
|
|
} else if c.Fs.IsPermission(err) {
|
|
|
return c.GetPermissionDeniedError()
|
|
|
+ } else if c.Fs.IsNotSupported(err) {
|
|
|
+ return c.GetOpUnsupportedError()
|
|
|
} else if err != nil {
|
|
|
return c.GetGenericError(err)
|
|
|
}
|