alex-mindspace commited on
Commit
b3426f6
·
1 Parent(s): c1ddd72

Upload 38 files

Browse files
Files changed (1) hide show
  1. swarmai/Swarm.py +7 -2
swarmai/Swarm.py CHANGED
@@ -218,8 +218,13 @@ class Swarm:
218
  self.data_dir = Path(".", config["swarm"]["run_dir"]).resolve()
219
  # first, try to delete the directory with all the data
220
  try:
221
- shutil.rmtree(self.data_dir)
222
- self.log(f"Deleted the directory {self.data_dir}")
 
 
 
 
 
223
  except Exception:
224
  pass
225
 
 
218
  self.data_dir = Path(".", config["swarm"]["run_dir"]).resolve()
219
  # first, try to delete the directory with all the data
220
  try:
221
+ # delete all files and subdirectories in the data directory
222
+ for dir_i in self.data_dir.iterdir():
223
+ if dir_i.is_dir():
224
+ shutil.rmtree(dir_i)
225
+ else:
226
+ dir_i.unlink()
227
+ self.log(f"Deleted old {dir_i}")
228
  except Exception:
229
  pass
230