Fix symlink not being created for duplicated IOU devices. Fixes https://github.com/GNS3/gns3-gui/issues/2699

This commit is contained in:
grossmj 2019-02-19 00:09:59 +08:00
parent 4ecd3b2015
commit 589c9754e8
2 changed files with 4 additions and 3 deletions

View File

@ -276,7 +276,7 @@ class BaseManager:
destination_dir = destination_node.working_dir
try:
shutil.rmtree(destination_dir)
shutil.copytree(source_node.working_dir, destination_dir)
shutil.copytree(source_node.working_dir, destination_dir, symlinks=True, ignore_dangling_symlinks=True)
except OSError as e:
raise aiohttp.web.HTTPConflict(text="Can't duplicate node data: {}".format(e))

View File

@ -522,8 +522,9 @@ class IOUVM(BaseNode):
# on newer images, see https://github.com/GNS3/gns3-server/issues/1484
try:
symlink = os.path.join(self.working_dir, os.path.basename(self.path))
if not os.path.islink(symlink):
os.symlink(self.path, symlink)
if os.path.islink(symlink):
os.unlink(symlink)
os.symlink(self.path, symlink)
except OSError as e:
raise IOUError("Could not create symbolic link: {}".format(e))