(file *protocol.FileInfo, path string)
| 17 | ) |
| 18 | |
| 19 | func (f *sendReceiveFolder) syncOwnership(file *protocol.FileInfo, path string) error { |
| 20 | if file.Platform.Unix == nil { |
| 21 | // No owner data, nothing to do |
| 22 | return nil |
| 23 | } |
| 24 | |
| 25 | // Try to look up the user and group by name, defaulting to the |
| 26 | // numerical UID and GID if there is no match. |
| 27 | |
| 28 | uid := strconv.Itoa(file.Platform.Unix.UID) |
| 29 | if file.Platform.Unix.OwnerName != "" { |
| 30 | us, err := user.Lookup(file.Platform.Unix.OwnerName) |
| 31 | if err == nil && us.Uid != "" { |
| 32 | uid = us.Uid |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | gid := strconv.Itoa(file.Platform.Unix.GID) |
| 37 | if file.Platform.Unix.GroupName != "" { |
| 38 | gr, err := user.LookupGroup(file.Platform.Unix.GroupName) |
| 39 | if err == nil && gr.Gid != "" { |
| 40 | gid = gr.Gid |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | return f.mtimefs.Lchown(path, uid, gid) |
| 45 | } |
no test coverage detected