From ced228473134664710e3718d0a5977e889cf2dbe Mon Sep 17 00:00:00 2001 From: Austin Gibbons Date: Thu, 25 Feb 2021 10:07:57 -0500 Subject: [PATCH] Modified return value for images that are already mounted. --- src/thumbtack/utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/thumbtack/utils.py b/src/thumbtack/utils.py index 3a361e9..e4b62b9 100644 --- a/src/thumbtack/utils.py +++ b/src/thumbtack/utils.py @@ -116,10 +116,6 @@ def mount_image(relative_image_path): if not image_info: raise ImageNotInDatabaseError - if image_info["status"] == "Mounted": - increment_ref_count(relative_image_path) - return image_info - # Verify we have a valid file path if not os.access(full_image_path, os.R_OK): msg = f"* {relative_image_path} is not a valid file or is not accessible for reading" @@ -136,6 +132,11 @@ def mount_image(relative_image_path): for _ in image_parser.init(): pass + if image_info["status"] == "Mounted": + increment_ref_count(relative_image_path) + current_app.logger.info(f"* {relative_image_path} is already mounted") + return image_parser.disks[0] + # thumbtack can only handle images that have one disk num_disks = len(image_parser.disks) if num_disks != 1: