From 048d2c12d055d707bd569c62469306e4b2a404b7 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 26 Oct 2016 10:53:14 +0200 Subject: [PATCH] Catch permission errors when listing images Fix #1608 --- gns3server/controller/compute.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index 457a0dbb..68dd397e 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -539,15 +539,18 @@ class Compute: res = yield from self.http_query("GET", "/{}/images".format(type), timeout=120) images = res.json - if type in ["qemu", "dynamips", "iou"]: - for path in scan_for_images(type): - image = os.path.basename(path) - if image not in [i['filename'] for i in images]: - images.append({"filename": image, - "path": image, - "md5sum": md5sum(path), - "filesize": os.stat(path).st_size - }) + try: + if type in ["qemu", "dynamips", "iou"]: + for path in scan_for_images(type): + image = os.path.basename(path) + if image not in [i['filename'] for i in images]: + images.append({"filename": image, + "path": image, + "md5sum": md5sum(path), + "filesize": os.stat(path).st_size + }) + except OSError as e: + raise aiohttp.web.HTTPConflict(text="Can't scan for images: {}".format(str(e))) return images @asyncio.coroutine