Skip to content

Commit

Permalink
Modified return value for images that are already mounted.
Browse files Browse the repository at this point in the history
  • Loading branch information
agibbons27 committed Feb 25, 2021
1 parent 65ae62f commit ced2284
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/thumbtack/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand Down

0 comments on commit ced2284

Please sign in to comment.