@@ -50,17 +50,14 @@ def cleanup(delay=2, test=False):
5050 # For named image dir, look at the what the symlink points at
5151 for named_image in named_image_dir :
5252 link_target = os .readlink (named_image )
53- # Multiple images can point to the same image_dir
54- if link_target not in image_dirs :
55- print ("%s not in list of image directories from %s" % (link_target , named_image ))
56- else :
53+ while link_target in image_dirs :
5754 image_dirs .remove (link_target )
55+ # Remove linked image from json (in case link is restored)
56+ json_missing_links .pop (link_target , None )
5857
5958 # Now, for each image, see if it's in the json
6059 for image_dir in image_dirs :
61- if image_dir in json_missing_links :
62- image_dirs .remove (image_dir )
63- else :
60+ if image_dir not in json_missing_links :
6461 # Add it to the json
6562 print ("Newly found missing link: %s" % (image_dir ))
6663 json_missing_links [image_dir ] = int (time .time ())
@@ -70,6 +67,9 @@ def cleanup(delay=2, test=False):
7067 for image_dir , last_linked in json_missing_links .items ():
7168 date_last_linked = datetime .fromtimestamp (last_linked )
7269 if date_last_linked < expiry :
70+ # Confirm that we're inside the managed directory
71+ if not image_dir .startswith (SINGULARITY_BASE ):
72+ continue
7373 # Remove the directory
7474 print ("Removing missing link: %s" % image_dir )
7575 if not test :
0 commit comments