lib/model, lib/protocol, lib/scanner: Include symlink target in index, pull symlinks synchronously

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3792
This commit is contained in:
Jakob Borg
2016-12-09 18:02:18 +00:00
committed by Audrius Butkevicius
parent f6a2b6252a
commit 7b07ed6580
12 changed files with 393 additions and 285 deletions

View File

@@ -35,7 +35,3 @@ func Read(path string) (string, TargetType, error) {
func Create(source, target string, tt TargetType) error {
return os.Symlink(osutil.NativeFilename(target), source)
}
func ChangeType(path string, tt TargetType) error {
return nil
}

View File

@@ -166,25 +166,3 @@ func Create(source, target string, tt TargetType) error {
}
return err
}
func ChangeType(path string, tt TargetType) error {
target, exTt, err := Read(path)
if err != nil {
return err
}
// If it's the same type, nothing to do.
if tt == exTt {
return nil
}
// If the actual type is unknown, but the new type is file, nothing to do
if exTt == TargetUnknown && tt != TargetDirectory {
return nil
}
return osutil.InWritableDir(func(path string) error {
// It should be a symlink as well hence no need to change permissions on
// the file.
os.Remove(path)
return Create(path, target, tt)
}, path)
}