Skip to content

Commit

Permalink
Merge pull request #2360 from GNS3/bugfix/3555
Browse files Browse the repository at this point in the history
Fix export project
  • Loading branch information
grossmj committed Feb 26, 2024
2 parents 14a6187 + 52638a9 commit d100a13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gns3server/controller/export_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ async def export_project(zstream, project, temporary_dir, include_images=False,
continue
_patch_mtime(path)
zstream.write(path, os.path.relpath(path, project._path))
# save empty directories
for directory in dirs:
path = os.path.join(root, directory)
if not os.listdir(path):
zstream.write(path, os.path.relpath(path, project._path))
except FileNotFoundError as e:
log.warning("Cannot export local file: {}".format(e))
continue
Expand Down
2 changes: 2 additions & 0 deletions tests/controller/test_export_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ async def test_export(tmpdir, project):
f.write("HELLO")
with open(os.path.join(path, "vm-1", "dynamips", "test_log.txt"), 'w+') as f:
f.write("LOG")
os.makedirs(os.path.join(path, "vm-1", "dynamips", "empty-dir"))
os.makedirs(os.path.join(path, "project-files", "snapshots"))
with open(os.path.join(path, "project-files", "snapshots", "test"), 'w+') as f:
f.write("WORLD")
Expand All @@ -127,6 +128,7 @@ async def test_export(tmpdir, project):

assert 'test.gns3' not in myzip.namelist()
assert 'project.gns3' in myzip.namelist()
assert 'vm-1/dynamips/empty-dir/' in myzip.namelist()
assert 'project-files/snapshots/test' not in myzip.namelist()
assert 'vm-1/dynamips/test_log.txt' not in myzip.namelist()

Expand Down

0 comments on commit d100a13

Please sign in to comment.