Allow existing empty dir when migrating files
Remove old empty directory if it exists - otherwise, we move old/data to new/data/data.
This commit is contained in:
parent
0498e042a0
commit
f7d17c4c55
@ -359,9 +359,11 @@ def _move_data(old, new):
|
|||||||
log.init.debug("Migrating data from {} to {}".format(old, new))
|
log.init.debug("Migrating data from {} to {}".format(old, new))
|
||||||
|
|
||||||
if os.path.exists(new):
|
if os.path.exists(new):
|
||||||
message.error("Failed to move data from {} as {} already exists!"
|
if os.listdir(new):
|
||||||
|
message.error("Failed to move data from {} as {} is non-empty!"
|
||||||
.format(old, new))
|
.format(old, new))
|
||||||
return False
|
return False
|
||||||
|
os.rmdir(new)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shutil.move(old, new)
|
shutil.move(old, new)
|
||||||
|
@ -389,7 +389,7 @@ class TestDataMigrations:
|
|||||||
standarddir._move_webengine_data()
|
standarddir._move_webengine_data()
|
||||||
|
|
||||||
record = caplog.records[-1]
|
record = caplog.records[-1]
|
||||||
expected = "Failed to move data from {} as {} already exists!".format(
|
expected = "Failed to move data from {} as {} is non-empty!".format(
|
||||||
old_path, new_path)
|
old_path, new_path)
|
||||||
assert record.message == expected
|
assert record.message == expected
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user