This fixes a mistake introduced in #4750 and #4776 and is relevant to v0.14.46-rc1
This commit is contained in:
@@ -308,7 +308,7 @@ func (w *walker) walkRegular(ctx context.Context, relPath string, info fs.FileIn
|
||||
// currently have. Keeping only our local counter makes sure we are in
|
||||
// conflict with any other existing versions, which will be resolved by
|
||||
// the normal pulling mechanisms.
|
||||
f.Version.DropOthers(w.ShortID)
|
||||
f.Version = f.Version.DropOthers(w.ShortID)
|
||||
}
|
||||
l.Debugln("rescan:", cf, info.ModTime().Unix(), info.Mode()&fs.ModePerm)
|
||||
}
|
||||
@@ -347,7 +347,7 @@ func (w *walker) walkDir(ctx context.Context, relPath string, info fs.FileInfo,
|
||||
// currently have. Keeping only our local counter makes sure we are in
|
||||
// conflict with any other existing versions, which will be resolved by
|
||||
// the normal pulling mechanisms.
|
||||
f.Version.DropOthers(w.ShortID)
|
||||
f.Version = f.Version.DropOthers(w.ShortID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ func (w *walker) walkSymlink(ctx context.Context, relPath string, dchan chan pro
|
||||
// currently have. Keeping only our local counter makes sure we are in
|
||||
// conflict with any other existing versions, which will be resolved by
|
||||
// the normal pulling mechanisms.
|
||||
f.Version.DropOthers(w.ShortID)
|
||||
f.Version = f.Version.DropOthers(w.ShortID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -522,6 +522,52 @@ func TestIssue4799(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssue4841(t *testing.T) {
|
||||
tmp, err := ioutil.TempDir("", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(tmp)
|
||||
|
||||
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, tmp)
|
||||
|
||||
fd, err := fs.Create("foo")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fd.Close()
|
||||
|
||||
fchan := Walk(context.TODO(), Config{
|
||||
Filesystem: fs,
|
||||
Subs: nil,
|
||||
BlockSize: 128 * 1024,
|
||||
AutoNormalize: true,
|
||||
Hashers: 2,
|
||||
CurrentFiler: fakeCurrentFiler{
|
||||
"foo": {
|
||||
Name: "foo",
|
||||
Type: protocol.FileInfoTypeFile,
|
||||
Invalid: true,
|
||||
Version: protocol.Vector{}.Update(1),
|
||||
},
|
||||
},
|
||||
ShortID: protocol.LocalDeviceID.Short(),
|
||||
})
|
||||
|
||||
var files []protocol.FileInfo
|
||||
for f := range fchan {
|
||||
files = append(files, f)
|
||||
}
|
||||
sort.Sort(fileList(files))
|
||||
|
||||
if len(files) != 1 {
|
||||
t.Fatalf("Expected 1 file, got %d: %v", len(files), files)
|
||||
}
|
||||
if expected := (protocol.Vector{}.Update(protocol.LocalDeviceID.Short())); !files[0].Version.Equal(expected) {
|
||||
t.Fatalf("Expected Version == %v, got %v", expected, files[0].Version)
|
||||
}
|
||||
}
|
||||
|
||||
// Verify returns nil or an error describing the mismatch between the block
|
||||
// list and actual reader contents
|
||||
func verify(r io.Reader, blocksize int, blocks []protocol.BlockInfo) error {
|
||||
@@ -553,3 +599,10 @@ func verify(r io.Reader, blocksize int, blocks []protocol.BlockInfo) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type fakeCurrentFiler map[string]protocol.FileInfo
|
||||
|
||||
func (fcf fakeCurrentFiler) CurrentFile(name string) (protocol.FileInfo, bool) {
|
||||
f, ok := fcf[name]
|
||||
return f, ok
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user