mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Fix export for missing files
This commit is contained in:
parent
7542b28793
commit
6120736c91
@ -66,6 +66,7 @@ async def export_project(zstream, project, temporary_dir, include_images=False,
|
|||||||
|
|
||||||
# Export the local files
|
# Export the local files
|
||||||
for root, dirs, files in os.walk(project._path, topdown=True, followlinks=False):
|
for root, dirs, files in os.walk(project._path, topdown=True, followlinks=False):
|
||||||
|
try:
|
||||||
files = [f for f in files if _is_exportable(os.path.join(root, f), include_snapshots)]
|
files = [f for f in files if _is_exportable(os.path.join(root, f), include_snapshots)]
|
||||||
for file in files:
|
for file in files:
|
||||||
path = os.path.join(root, file)
|
path = os.path.join(root, file)
|
||||||
@ -82,6 +83,9 @@ async def export_project(zstream, project, temporary_dir, include_images=False,
|
|||||||
continue
|
continue
|
||||||
_patch_mtime(path)
|
_patch_mtime(path)
|
||||||
zstream.write(path, os.path.relpath(path, project._path))
|
zstream.write(path, os.path.relpath(path, project._path))
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
log.warning("Cannot export local file: {}".format(e))
|
||||||
|
continue
|
||||||
|
|
||||||
# Export files from remote computes
|
# Export files from remote computes
|
||||||
for compute in project.computes:
|
for compute in project.computes:
|
||||||
@ -91,8 +95,9 @@ async def export_project(zstream, project, temporary_dir, include_images=False,
|
|||||||
if _is_exportable(compute_file["path"], include_snapshots):
|
if _is_exportable(compute_file["path"], include_snapshots):
|
||||||
log.debug("Downloading file '{}' from compute '{}'".format(compute_file["path"], compute.id))
|
log.debug("Downloading file '{}' from compute '{}'".format(compute_file["path"], compute.id))
|
||||||
response = await compute.download_file(project, compute_file["path"])
|
response = await compute.download_file(project, compute_file["path"])
|
||||||
#if response.status != 200:
|
if response.status != 200:
|
||||||
# raise aiohttp.web.HTTPConflict(text="Cannot export file from compute '{}'. Compute returned status code {}.".format(compute.id, response.status))
|
log.warning("Cannot export file from compute '{}'. Compute returned status code {}.".format(compute.id, response.status))
|
||||||
|
continue
|
||||||
(fd, temp_path) = tempfile.mkstemp(dir=temporary_dir)
|
(fd, temp_path) = tempfile.mkstemp(dir=temporary_dir)
|
||||||
async with aiofiles.open(fd, 'wb') as f:
|
async with aiofiles.open(fd, 'wb') as f:
|
||||||
while True:
|
while True:
|
||||||
@ -130,10 +135,6 @@ def _is_exportable(path, include_snapshots=False):
|
|||||||
:returns: True if file should not be included in the final archive
|
:returns: True if file should not be included in the final archive
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# do not export file that does not exist anymore
|
|
||||||
if not os.path.exists(path):
|
|
||||||
return False
|
|
||||||
|
|
||||||
# do not export snapshots by default
|
# do not export snapshots by default
|
||||||
if include_snapshots is False and path.endswith("snapshots"):
|
if include_snapshots is False and path.endswith("snapshots"):
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user