From 7683a79bb1a9502f43ab60ee7c17335d74e6bc21 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 27 Jul 2017 11:42:10 +0200 Subject: [PATCH] Fix OSError when uploading images Fix #1101 --- gns3server/controller/node.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py index b7050045..de480906 100644 --- a/gns3server/controller/node.py +++ b/gns3server/controller/node.py @@ -541,8 +541,11 @@ class Node: image = os.path.join(directory, img) if os.path.exists(image): self.project.controller.notification.emit("log.info", {"message": "Uploading missing image {}".format(img)}) - with open(image, 'rb') as f: - yield from self._compute.post("/{}/images/{}".format(self._node_type, os.path.basename(img)), data=f, timeout=None) + try: + with open(image, 'rb') as f: + yield from self._compute.post("/{}/images/{}".format(self._node_type, os.path.basename(img)), data=f, timeout=None) + except OSError as e: + raise aiohttp.web.HTTPConflict(text="Can't upload {}: {}".format(image, str(e))) self.project.controller.notification.emit("log.info", {"message": "Upload finished for {}".format(img)}) return True return False