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
+3 -3
View File
@@ -66,7 +66,7 @@ type FileInfo struct {
Version Vector
Sequence int64
Blocks []BlockInfo
SymlinkTarget string
SymlinkTarget []byte
BlocksHash []byte
Encrypted []byte
Platform PlatformData
@@ -187,7 +187,7 @@ type FileInfoWithoutBlocks interface {
GetVersion() *bep.Vector
GetSequence() int64
// GetBlocks() []*bep.BlockInfo // not included
GetSymlinkTarget() string
GetSymlinkTarget() []byte
GetBlocksHash() []byte
GetEncrypted() []byte
GetType() FileInfoType
@@ -469,7 +469,7 @@ func (f FileInfo) isEquivalent(other FileInfo, comp FileInfoComparison) bool {
case FileInfoTypeFile:
return f.Size == other.Size && ModTimeEqual(f.ModTime(), other.ModTime(), comp.ModTimeWindow) && (comp.IgnoreBlocks || f.BlocksEqual(other))
case FileInfoTypeSymlink:
return f.SymlinkTarget == other.SymlinkTarget
return bytes.Equal(f.SymlinkTarget, other.SymlinkTarget)
case FileInfoTypeDirectory:
return true
}
+4 -4
View File
@@ -185,15 +185,15 @@ func TestIsEquivalent(t *testing.T) {
// The symlink target is checked for symlinks
{
a: FileInfo{Type: FileInfoTypeSymlink, SymlinkTarget: "a"},
b: FileInfo{Type: FileInfoTypeSymlink, SymlinkTarget: "b"},
a: FileInfo{Type: FileInfoTypeSymlink, SymlinkTarget: []byte("a")},
b: FileInfo{Type: FileInfoTypeSymlink, SymlinkTarget: []byte("b")},
eq: false,
},
// ... but not for non-symlinks
{
a: FileInfo{Type: FileInfoTypeFile, SymlinkTarget: "a"},
b: FileInfo{Type: FileInfoTypeFile, SymlinkTarget: "b"},
a: FileInfo{Type: FileInfoTypeFile, SymlinkTarget: []byte("a")},
b: FileInfo{Type: FileInfoTypeFile, SymlinkTarget: []byte("b")},
eq: true,
},
}