fix: data loss bug when move + delete (#162)
This commit is contained in:
parent
2fde9d84fc
commit
f86d49446a
2 changed files with 21 additions and 8 deletions
|
|
@ -191,7 +191,7 @@ M.enforce_action_order = function(actions)
|
||||||
local function get_deps(action)
|
local function get_deps(action)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
if action.type == "delete" then
|
if action.type == "delete" then
|
||||||
return ret
|
src_trie:accum_children_of(action.url, ret)
|
||||||
elseif action.type == "create" then
|
elseif action.type == "create" then
|
||||||
-- Finish operating on parents first
|
-- Finish operating on parents first
|
||||||
-- e.g. NEW /a BEFORE NEW /a/b
|
-- e.g. NEW /a BEFORE NEW /a/b
|
||||||
|
|
|
||||||
|
|
@ -409,6 +409,19 @@ a.describe("mutator", function()
|
||||||
assert.are.same({ create, move }, ordered_actions)
|
assert.are.same({ create, move }, ordered_actions)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("Moves file out of parent before deleting parent", function()
|
||||||
|
local move = {
|
||||||
|
type = "move",
|
||||||
|
src_url = "oil-test:///a/b.txt",
|
||||||
|
dest_url = "oil-test:///b.txt",
|
||||||
|
entry_type = "file",
|
||||||
|
}
|
||||||
|
local delete = { type = "delete", url = "oil-test:///a", entry_type = "directory" }
|
||||||
|
local actions = { delete, move }
|
||||||
|
local ordered_actions = mutator.enforce_action_order(actions)
|
||||||
|
assert.are.same({ move, delete }, ordered_actions)
|
||||||
|
end)
|
||||||
|
|
||||||
it("Handles parent child move ordering", function()
|
it("Handles parent child move ordering", function()
|
||||||
-- move parent into a child and child OUT of parent
|
-- move parent into a child and child OUT of parent
|
||||||
-- MOVE /a/b -> /b
|
-- MOVE /a/b -> /b
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue