Skip to content

Commit

Permalink
core/local/change: unlink+add(existing) is an overwrite (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
aenario authored and sebn committed Sep 28, 2018
1 parent cfd4ed0 commit a4b3197
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/local/change.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const sideName = 'local'
function build (type /*: string */, path /*: string */, opts /*: ?{stats?: fs.Stats, md5sum?: string, old?: ?Metadata} */) /*: LocalChange */ {
const change /*: Object */ = _.assign({sideName, type, path}, opts)
if (change.wip == null) delete change.wip
if (change.overwrite == null) delete change.overwrite
if (change.md5sum == null) delete change.md5sum
return change
}
Expand Down Expand Up @@ -169,6 +170,7 @@ function dirMoveFromUnlinkAdd (unlinkChange /*: LocalDirDeletion */, e /*: Local
stats: e.stats,
old: unlinkChange.old,
ino: unlinkChange.ino,
overwrite: e.old,
wip: e.wip
})
}
Expand Down
13 changes: 13 additions & 0 deletions test/scenarios/move_overwriting_dir/local/finder_manual.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
"ctime": "2017-10-09T13:22:01.546Z"
}
},
{
"type": "addDir",
"path": "dst/dir/subdir/subsub",
"stats": {
"ino": 15,
"mtime": "2017-10-09T13:21:59.535Z",
"ctime": "2017-10-09T13:22:01.546Z"
}
},
{
"type": "addDir",
"path": "dst/dir",
Expand All @@ -45,6 +54,10 @@
"type": "unlink",
"path": "dst/dir/subdir/file5"
},
{
"type": "unlinkDir",
"path": "dst/dir/subdir/subsub"
},
{
"type": "unlink",
"path": "dst/dir/subdir/file"
Expand Down
4 changes: 3 additions & 1 deletion test/scenarios/move_overwriting_dir/scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = ({
{ ino: 11, path: 'src/dir/file', content: 'overwriter' },
{ ino: 12, path: 'src/dir/subdir/file', content: 'sub-overwriter' },
{ ino: 13, path: 'src/dir/subdir/file6', content: 'sub-other' },
{ ino: 14, path: 'src/dir/file2', content: 'other' }
{ ino: 14, path: 'src/dir/file2', content: 'other' },
{ ino: 15, path: 'src/dir/subdir/subsub/' }
],
actions: [
{type: 'mv', force: true, src: 'src/dir', dst: 'dst/dir'}
Expand All @@ -39,6 +40,7 @@ module.exports = ({
'dst/dir/subdir/',
'dst/dir/subdir/file',
'dst/dir/subdir/file6',
'dst/dir/subdir/subsub/',
'src/'
],
// remoteTrash: [
Expand Down

0 comments on commit a4b3197

Please sign in to comment.