MCPcopy
hub / github.com/syncthing/syncthing / setPlatformData

Method setPlatformData

lib/model/folder_sendrecv.go:2154–2177  ·  view source on GitHub ↗

setPlatformData makes adjustments to the metadata that should happen for all types (files, directories, symlinks). This should be one of the last things we do to a file when syncing changes to it.

(file *protocol.FileInfo, name string)

Source from the content-addressed store, hash-verified

2152// all types (files, directories, symlinks). This should be one of the last
2153// things we do to a file when syncing changes to it.
2154func (f *sendReceiveFolder) setPlatformData(file *protocol.FileInfo, name string) error {
2155 if f.SyncXattrs {
2156 // Set extended attributes.
2157 if err := f.mtimefs.SetXattr(name, file.Platform.Xattrs(), f.XattrFilter); errors.Is(err, fs.ErrXattrsNotSupported) {
2158 f.sl.Debug("Cannot set xattrs (not supported)", slogutil.FilePath(file.Name), slogutil.Error(err))
2159 } else if err != nil {
2160 return err
2161 }
2162 }
2163
2164 if f.SyncOwnership {
2165 // Set ownership based on file metadata.
2166 if err := f.syncOwnership(file, name); err != nil {
2167 return err
2168 }
2169 } else if f.CopyOwnershipFromParent {
2170 // Copy the parent owner and group.
2171 if err := f.copyOwnershipFromParent(name); err != nil {
2172 return err
2173 }
2174 }
2175
2176 return nil
2177}
2178
2179func (f *sendReceiveFolder) copyOwnershipFromParent(path string) error {
2180 if build.IsWindows {

Callers 5

TestSetPlatformDataFunction · 0.95
handleDirMethod · 0.95
handleSymlinkMethod · 0.95
shortcutFileMethod · 0.95
performFinishMethod · 0.95

Calls 7

syncOwnershipMethod · 0.95
FilePathFunction · 0.92
ErrorFunction · 0.92
XattrsMethod · 0.80
SetXattrMethod · 0.65
IsMethod · 0.45

Tested by 1

TestSetPlatformDataFunction · 0.76