Skip to content

Commit 9532196

Browse files
committed
Fix cache.cdrop for index entries without corresponding file
1 parent 21385dc commit 9532196

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

climaf/cache.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ def op_squeezes_time(operator):
332332
co = crs2eval.get(crs, None)
333333
if co is None:
334334
try:
335-
clogger.debug("Cache hasMatching eval "+crs)
336335
save = env.environment.data_check
337336
env.environment.data_check = False
338337
co = eval(crs, sys.modules['__main__'].__dict__)
@@ -342,8 +341,6 @@ def op_squeezes_time(operator):
342341
if co:
343342
crs2eval[crs] = co
344343
# clogger.debug("Compare trees for %s and %s" % (crs, cobject.crs))
345-
clogger.debug("Cache hasMatching compare trees ")
346-
347344
altperiod = compare_trees(co, cobject, ds_func, op_squeezes_time)
348345
if altperiod:
349346
f, costs = crs2filename[crs]
@@ -479,6 +476,8 @@ def cdrop(obj, rm=True, force=False):
479476
fil, _ = crs2filename[crs]
480477
if not os.path.exists(fil):
481478
fil = alternate_filename(fil)
479+
if not os.path.exists(fil):
480+
fil = None
482481
else:
483482
# In case the cache index is not up-to-date
484483
fil, cost = hasExactObject(obj)
@@ -490,7 +489,7 @@ def cdrop(obj, rm=True, force=False):
490489
if force:
491490
os.system("chmod +w " + fil)
492491
if not os.access(fil, os.W_OK):
493-
clogger.info("Object %s is protected" % crs)
492+
clogger.info("Object %s is protected, file is %s" % (crs,fil))
494493
return
495494
path_file = os.path.dirname(fil)
496495
os.remove(fil)
@@ -506,7 +505,9 @@ def cdrop(obj, rm=True, force=False):
506505
"When trying to remove %s : file does not exist in cache" % crs)
507506
return False
508507
else:
509-
clogger.info("%s is not cached" % crs)
508+
clogger.info("%s is not cached and will be removed from index" % crs)
509+
crs2filename.pop(crs,None)
510+
dropped_crs.append(crs)
510511
return None
511512

512513

@@ -699,7 +700,7 @@ def craz(force=False, hideError=False):
699700
generateUniqueFileName(crs))
700701
else:
701702
clogger.debug(
702-
'Could not remove file (either not existing or protected): %s', crs2filename[crs])
703+
'Could not remove file (either not existing or protected)')
703704
clogger.debug('Associated CRS : %s', crs)
704705
# os.system("ls " + cc)
705706

0 commit comments

Comments
 (0)