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:
committed by
Audrius Butkevicius
parent
f6a2b6252a
commit
7b07ed6580
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user