Serdar commited on
Commit
1fa0332
1 Parent(s): 5df3267
sabiduria_tool_api/services/service_sabiduria_tool.py CHANGED
@@ -27,19 +27,15 @@ class FileProcess:
27
  }
28
 
29
  async def save_files(self) -> None:
30
- try:
31
- if not isdir(self.data_store_path):
32
- mkdir(self.data_store_path)
33
- except Exception as e:
34
- logger.error(f"Error creating directory: {e}")
35
- return
36
-
37
  for file in self.files:
38
- try:
39
- with open(f"{self.data_store_path}{file.filename}", "wb") as destination:
40
- copyfileobj(file.file, destination)
41
- except Exception as e:
42
- logger.error(f"Error saving file: {e}")
43
 
44
 
45
  def get_files(self) -> list:
 
27
  }
28
 
29
  async def save_files(self) -> None:
30
+ if isdir(self.data_store_path):
31
+ old_files = self.get_files()
32
+ for o_file in old_files:
33
+ remove(f"{self.data_store_path}{o_file}")
34
+ else:
35
+ mkdir(self.data_store_path)
 
36
  for file in self.files:
37
+ with open(f"{self.data_store_path}{file.filename}", "wb") as destination:
38
+ copyfileobj(file.file, destination)
 
 
 
39
 
40
 
41
  def get_files(self) -> list: