mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 16:54:51 +02:00
Keep forever .gns3 backup before version upgrade
This commit is contained in:
parent
98480881a3
commit
a437760f5d
@ -98,7 +98,7 @@ def load_topology(path):
|
||||
if "revision" not in topo or topo["revision"] < GNS3_FILE_FORMAT_REVISION:
|
||||
# If it's an old GNS3 file we need to convert it
|
||||
# first we backup the file
|
||||
shutil.copy(path, path + ".backup")
|
||||
shutil.copy(path, path + ".backup{}".format(topo.get("revision", 0)))
|
||||
topo = _convert_1_3_later(topo, path)
|
||||
with open(path, "w+", encoding="utf-8") as f:
|
||||
json.dump(topo, f)
|
||||
|
@ -68,7 +68,7 @@ def test_convert(directory, tmpdir):
|
||||
assert work_topology
|
||||
|
||||
if "revision" not in before_topology or before_topology["revision"] < GNS3_FILE_FORMAT_REVISION:
|
||||
assert os.path.exists(os.path.join(work_directory, gns3_file + ".backup"))
|
||||
assert os.path.exists(os.path.join(work_directory, gns3_file + ".backup{}".format(before_topology.get("revision", 0))))
|
||||
|
||||
# We should have the same file in after directory and the work directory
|
||||
for root, dirs, files in os.walk(after_directory):
|
||||
@ -92,7 +92,7 @@ def test_convert(directory, tmpdir):
|
||||
directory = os.path.relpath(root, work_directory)
|
||||
file_path = os.path.join(after_directory, directory, file)
|
||||
# .backup are created by the conversion process
|
||||
if not file.endswith(".backup"):
|
||||
if ".backup" not in file_path:
|
||||
assert os.path.exists(file_path), "{} should not be here".format(os.path.join(directory, file))
|
||||
|
||||
compare_dict("/", work_topology, after_topology)
|
||||
|
Loading…
Reference in New Issue
Block a user