sync: Track and perform server-side renames

This commits adds support for tracking of file renames if `track-renames` flag is set,
and it then performs server-side renames for remotes that support it, i.e.
remotes that implement either the `Mover` or the `Copier` interface.

Fixes #888
This commit is contained in:
Bjørn Erik Pedersen
2017-01-03 20:35:05 +00:00
committed by Nick Craig-Wood
parent 5c89fd679d
commit 47d3a450a4
5 changed files with 156 additions and 11 deletions
+13
View File
@@ -168,6 +168,19 @@ func NewRun(t *testing.T) *Run {
return r
}
// Rename a file in local
func (r *Run) RenameFile(item fstest.Item, newpath string) fstest.Item {
oldFilepath := path.Join(r.localName, item.Path)
newFilepath := path.Join(r.localName, newpath)
if err := os.Rename(oldFilepath, newFilepath); err != nil {
r.Fatalf("Failed to rename file from %q to %q: %v", item.Path, newpath, err)
}
item.Path = newpath
return item
}
// Write a file to local
func (r *Run) WriteFile(filePath, content string, t time.Time) fstest.Item {
item := fstest.NewItem(filePath, content, t)