mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-06-18 15:28:11 +00:00
Do not export/import symlinks for projects. Fixes #2699
This commit is contained in:
@ -64,7 +64,7 @@ def export_project(project, temporary_dir, include_images=False, keep_compute_id
|
||||
yield from _patch_project_file(project, os.path.join(project._path, file), zstream, include_images, keep_compute_id, allow_all_nodes, temporary_dir)
|
||||
|
||||
# Export the local files
|
||||
for root, dirs, files in os.walk(project._path, topdown=True):
|
||||
for root, dirs, files in os.walk(project._path, topdown=True, followlinks=False):
|
||||
files = [f for f in files if _is_exportable(os.path.join(root, f))]
|
||||
for file in files:
|
||||
path = os.path.join(root, file)
|
||||
@ -125,6 +125,7 @@ def _patch_mtime(path):
|
||||
new_mtime = file_date.replace(year=1980).timestamp()
|
||||
os.utime(path, (st.st_atime, new_mtime))
|
||||
|
||||
|
||||
def _is_exportable(path):
|
||||
"""
|
||||
:returns: True if file should not be included in the final archive
|
||||
@ -134,6 +135,10 @@ def _is_exportable(path):
|
||||
if path.endswith("snapshots"):
|
||||
return False
|
||||
|
||||
# do not export symlinks
|
||||
if os.path.islink(path):
|
||||
return False
|
||||
|
||||
# do not export directories of snapshots
|
||||
if "{sep}snapshots{sep}".format(sep=os.path.sep) in path:
|
||||
return False
|
||||
|
Reference in New Issue
Block a user