chore(proto): change symlinktarget to be byte sequence (fixes #9913) (#9914)

This commit is contained in:
Jakob Borg
2025-01-11 17:38:29 +01:00
committed by GitHub
parent ab20c16982
commit 516f3e29e8
11 changed files with 24 additions and 24 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ func (f *fakeConnection) addFileLocked(name string, flags uint32, ftype protocol
file.Name = name
file.Type = ftype
file.Version = version
file.SymlinkTarget = string(data)
file.SymlinkTarget = data
file.NoPermissions = true
}
f.files = append(f.files, file)
+2 -2
View File
@@ -743,7 +743,7 @@ func (f *sendReceiveFolder) handleSymlink(file protocol.FileInfo, snap *db.Snaps
l.Debugf("need symlink\n\t%v\n\t%v", file, curFile)
}
if file.SymlinkTarget == "" {
if len(file.SymlinkTarget) == 0 {
// Index entry from a Syncthing predating the support for including
// the link target in the index entry. We log this as an error.
f.newPullError(file.Name, errIncompatibleSymlink)
@@ -758,7 +758,7 @@ func (f *sendReceiveFolder) handleSymlink(file protocol.FileInfo, snap *db.Snaps
// We declare a function that acts on only the path name, so
// we can pass it to InWritableDir.
createLink := func(path string) error {
if err := f.mtimefs.CreateSymlink(file.SymlinkTarget, path); err != nil {
if err := f.mtimefs.CreateSymlink(string(file.SymlinkTarget), path); err != nil {
return err
}
return f.setPlatformData(&file, path)
+2 -2
View File
@@ -891,7 +891,7 @@ func TestCopyOwner(t *testing.T) {
Name: "foo/bar/sym",
Type: protocol.FileInfoTypeSymlink,
Permissions: 0o644,
SymlinkTarget: "over the rainbow",
SymlinkTarget: []byte("over the rainbow"),
}
f.handleSymlink(symlink, snap, dbUpdateChan, scanChan)
@@ -958,7 +958,7 @@ func TestSRConflictReplaceFileByLink(t *testing.T) {
// Simulate remote creating a symlink with the same name
file.Type = protocol.FileInfoTypeSymlink
file.SymlinkTarget = "bar"
file.SymlinkTarget = []byte("bar")
rem := device1.Short()
file.Version = protocol.Vector{}.Update(rem)
file.ModifiedBy = rem