From a4b3197942f4bd5b565f5ee04feebd743951ae78 Mon Sep 17 00:00:00 2001 From: Romain Foucault Date: Fri, 28 Sep 2018 13:28:22 +0200 Subject: [PATCH] core/local/change: unlink+add(existing) is an overwrite (#1181) --- core/local/change.js | 2 ++ .../move_overwriting_dir/local/finder_manual.json | 13 +++++++++++++ test/scenarios/move_overwriting_dir/scenario.js | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/local/change.js b/core/local/change.js index 37819c953..759cbfef6 100644 --- a/core/local/change.js +++ b/core/local/change.js @@ -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 } @@ -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 }) } diff --git a/test/scenarios/move_overwriting_dir/local/finder_manual.json b/test/scenarios/move_overwriting_dir/local/finder_manual.json index 9c5ecca4b..f0fc652b9 100644 --- a/test/scenarios/move_overwriting_dir/local/finder_manual.json +++ b/test/scenarios/move_overwriting_dir/local/finder_manual.json @@ -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", @@ -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" diff --git a/test/scenarios/move_overwriting_dir/scenario.js b/test/scenarios/move_overwriting_dir/scenario.js index 217a69876..0ea525cbd 100644 --- a/test/scenarios/move_overwriting_dir/scenario.js +++ b/test/scenarios/move_overwriting_dir/scenario.js @@ -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'} @@ -39,6 +40,7 @@ module.exports = ({ 'dst/dir/subdir/', 'dst/dir/subdir/file', 'dst/dir/subdir/file6', + 'dst/dir/subdir/subsub/', 'src/' ], // remoteTrash: [