Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
mhewedy committed May 24, 2024
1 parent 81a0530 commit 1babb27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

def _cache_path(namespace, key=None):
cache_namespace = root_fs_cache + '/' + namespace
os.makedirs(cache_namespace, exist_ok=True)
if key:
os.makedirs(cache_namespace, exist_ok=True)
return os.path.join(cache_namespace, f'{key}.pkl')
else:
return cache_namespace
Expand All @@ -32,10 +32,10 @@ def put(namespace, key, value):
pickle.dump(value, f)


def clean(namespace):
def clear(namespace):
cache_namespace = _cache_path(namespace)
if os.path.exists(cache_namespace):
shutil.rmtree(cache_namespace)
logging.info(f'Cache for namespace {namespace} has been cleaned.')
logging.info(f'cache for namespace {namespace} has been cleared.')
else:
logging.warning(f'Cache for namespace {namespace} does not exist.')
logging.warning(f'cache for namespace {namespace} does not exist.')
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def clear_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
userSelector.clear_history()
if "+food" in context.args:
msg += " و تم مسح مخزون الأكلات"
cache.clean("food")
cache.clear("food")
await update.message.reply_text(msg)


Expand Down

0 comments on commit 1babb27

Please sign in to comment.