This adds support for syncing ownership on Unixes and on Windows. The scanner always picks up ownership information, but it is not applied unless the new folder option "Sync Ownership" is set. Ownership data is stored in a new FileInfo field called "platform data". This is intended to hold further platform-specific data in the future (specifically, extended attributes), which is why the whole design is a bit overkill for just ownership.
This commit is contained in:
@@ -12,6 +12,7 @@ package fs
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -57,6 +58,22 @@ func (f *BasicFilesystem) Roots() ([]string, error) {
|
||||
return []string{"/"}, nil
|
||||
}
|
||||
|
||||
func (f *BasicFilesystem) Lchown(name, uid, gid string) error {
|
||||
name, err := f.rooted(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nuid, err := strconv.Atoi(uid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ngid, err := strconv.Atoi(gid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Lchown(name, nuid, ngid)
|
||||
}
|
||||
|
||||
// unrootedChecked returns the path relative to the folder root (same as
|
||||
// unrooted) or an error if the given path is not a subpath and handles the
|
||||
// special case when the given path is the folder root without a trailing
|
||||
|
||||
Reference in New Issue
Block a user