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))
|
||||
|
||||
if os.path.exists(new):
|
||||
message.error("Failed to move data from {} as {} already exists!"
|
||||
.format(old, new))
|
||||
return False
|
||||
if os.listdir(new):
|
||||
message.error("Failed to move data from {} as {} is non-empty!"
|
||||
.format(old, new))
|
||||
return False
|
||||
os.rmdir(new)
|
||||
|
||||
try:
|
||||
shutil.move(old, new)
|
||||
|
@ -389,7 +389,7 @@ class TestDataMigrations:
|
||||
standarddir._move_webengine_data()
|
||||
|
||||
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)
|
||||
assert record.message == expected
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user