fix: process deletes in dir before moving dir
This commit is contained in:
parent
a632c898fb
commit
349bca8c3e
2 changed files with 23 additions and 4 deletions
|
|
@ -252,11 +252,10 @@ M.enforce_action_order = function(actions)
|
||||||
-- Process children before moving
|
-- Process children before moving
|
||||||
-- e.g. NEW /a/b BEFORE MOVE /a -> /b
|
-- e.g. NEW /a/b BEFORE MOVE /a -> /b
|
||||||
dest_trie:accum_children_of(action.src_url, ret)
|
dest_trie:accum_children_of(action.src_url, ret)
|
||||||
-- Copy children before moving parent dir
|
-- Process children before moving parent dir
|
||||||
-- e.g. COPY /a/b -> /b BEFORE MOVE /a -> /d
|
-- e.g. COPY /a/b -> /b BEFORE MOVE /a -> /d
|
||||||
src_trie:accum_children_of(action.src_url, ret, function(a)
|
-- e.g. CHANGE /a/b BEFORE MOVE /a -> /d
|
||||||
return a.type == "copy"
|
src_trie:accum_children_of(action.src_url, ret)
|
||||||
end)
|
|
||||||
-- Process remove path before moving to new path
|
-- Process remove path before moving to new path
|
||||||
-- e.g. MOVE /a -> /b BEFORE MOVE /c -> /a
|
-- e.g. MOVE /a -> /b BEFORE MOVE /c -> /a
|
||||||
src_trie:accum_actions_at(action.dest_url, ret, function(a)
|
src_trie:accum_actions_at(action.dest_url, ret, function(a)
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,26 @@ a.describe("mutator", function()
|
||||||
assert.are.same({ move1, move2 }, ordered_actions)
|
assert.are.same({ move1, move2 }, ordered_actions)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("Handles a delete inside a moved folder", function()
|
||||||
|
-- delete in directory and move directory
|
||||||
|
-- DELETE /a/b.txt
|
||||||
|
-- MOVE /a/ -> /b/
|
||||||
|
local del = {
|
||||||
|
type = "delete",
|
||||||
|
url = "oil-test:///a/b.txt",
|
||||||
|
entry_type = "file",
|
||||||
|
}
|
||||||
|
local move = {
|
||||||
|
type = "move",
|
||||||
|
src_url = "oil-test:///a",
|
||||||
|
dest_url = "oil-test:///b",
|
||||||
|
entry_type = "directory",
|
||||||
|
}
|
||||||
|
local actions = { move, del }
|
||||||
|
local ordered_actions = mutator.enforce_action_order(actions)
|
||||||
|
assert.are.same({ del, move }, ordered_actions)
|
||||||
|
end)
|
||||||
|
|
||||||
it("Detects move directory loops", function()
|
it("Detects move directory loops", function()
|
||||||
local move = {
|
local move = {
|
||||||
type = "move",
|
type = "move",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue