Repository navigation
Conversation
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 "OS data". This is intended to hold further OS specific data in the future (specifically, extended attributes), which is why the whole design is a bit overkill for just ownership.
| OS_WINDOWS = 2; | ||
| } | ||
|
|
||
| message POSIXOSData { |
There was a problem hiding this comment.
Feels like the OS part in the name is redundant?
Also, POSIX is not really an "OS", so if we decide to keep it, not sure I like the name? Perhaps "Platform" ?
| // POSIX data in the entry for OS_POSIX. The actual type of each entry | ||
| // is message ${OS}OSData. Protobuf doesn't have enum-keyed maps so this | ||
| // is an int32-keyed one instead, but the concept is the same. | ||
| map<int32, bytes> os_data = 14 [(gogoproto.castkey) = "OS", (ext.goname) = "OSData"]; |
There was a problem hiding this comment.
I guess I called out this before, but I dislike maps.
I guess we only want to have one of them here, so perhaps it's ok?
|
|
||
| // Copy OS data from src to dst, unless it was already set on dst. | ||
| if len(dst.OSData) == 0 { | ||
| dst.OSData = src.OSData |
There was a problem hiding this comment.
Is this really a copy? Haven't written go in a while at this point, but feels like if someone does a bunch of delete from the map, and you'd be chasing this rabbit for a while.
| // | ||
| // XXX: Technically, the serialized form of protobuf messages isn't | ||
| // guaranteed to be stable. In practice it is, and this is a much easier | ||
| // comparison than deserializing each thing. |
There was a problem hiding this comment.
For the purpose of "compatability" with other non-existing re-implementations, I wouldn't do this, and do it right.
I've also been hurt by this between different versions of proto packages (not that I think it matters to us too much).
| FilePermissions() uint32 | ||
| FileModifiedBy() ShortID | ||
| ModTime() time.Time | ||
| LoadOSData(os OS, dst interface{ Unmarshal([]byte) error }) bool |
There was a problem hiding this comment.
This is very yuck.
I'd rather had an explicit fields with data for each platform, i.e:
message PosixPlatformData {
...
}
message WindowsPlatformData {
...
}
message PlatformData {
PosixPlatformData posix = 1;
WindowsPlatformData windows = 2;
}
then, there is no loading magic, and you can just do have platform specific .apply(PlatformData) stuff.
| // The underlying filesystem must be a BasicFilesystem, because we're | ||
| // going to assume the file is an object on local disk and make system | ||
| // calls on it. | ||
| basic, ok := p.fs.(*BasicFilesystem) |
There was a problem hiding this comment.
/lib/fs/filesystem.go:unwrapFilesystem?
| l.Debugln("OS data for", rootedName, "is", pd) | ||
| return map[protocol.OS][]byte{ | ||
| protocol.OsWindows: bs, | ||
| }, nil |
There was a problem hiding this comment.
This always returns a map with one entry, feels like you could just return (type, byte[], error)
| root: root, | ||
| options: opts, | ||
| } | ||
| fs.OSDataGetter = NewOSDataGetter(fs) |
There was a problem hiding this comment.
This is somewhat grim, could we not have platform specific implementations for this, simillar like we have for notify etc?
This adds support for syncing ownership on Unixes and on Windows. The
mechanism is disabled unless the new folder option "Sync Ownership" is set.
Ownership data is stored in a new FileInfo field called "OS data". This
is intended to hold further OS specific data in the future
(specifically, extended attributes), which is why the whole design is a
bit overkill for just ownership.
https://github.com/syncthing/docs/pull/759/files