jfrery-zama commited on
Commit
009e9b1
·
1 Parent(s): 57f3a36

fix: tmp directory

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -32,12 +32,12 @@ transformer_vectorizer = TransformerVectorizer()
32
  def clean_tmp_directory():
33
  # Allow 20 user keys to be stored.
34
  # Once that limitation is reached, deleted the oldest.
35
- list_files = sorted(Path(".fhe_keys/").iterdir(), key=os.path.getmtime)
36
 
37
  user_ids = []
38
- if len(list_files) > N_USER_KEY_STORED:
39
- n_files_to_delete = len(list_files) - N_USER_KEY_STORED
40
- for p in list_files[:n_files_to_delete]:
41
  user_ids.append(p.name)
42
  shutil.rmtree(p)
43
 
 
32
  def clean_tmp_directory():
33
  # Allow 20 user keys to be stored.
34
  # Once that limitation is reached, deleted the oldest.
35
+ path_sub_directories = sorted([f for f in Path(".fhe_keys/").iterdir() if f.is_dir()], key=os.path.getmtime)
36
 
37
  user_ids = []
38
+ if len(path_sub_directories) > N_USER_KEY_STORED:
39
+ n_files_to_delete = len(path_sub_directories) - N_USER_KEY_STORED
40
+ for p in path_sub_directories[:n_files_to_delete]:
41
  user_ids.append(p.name)
42
  shutil.rmtree(p)
43