sivdead commited on
Commit
3e97c4b
1 Parent(s): b338c84

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -4,6 +4,7 @@ from git_commd import GitCommandWrapper
4
  from typing import List, Optional
5
  import logging
6
 
 
7
  HF_TOKEN = os.environ["HF_TOKEN"] if "HF_TOKEN" in os.environ else ""
8
  WiseModel_TOKEN = os.environ["WM_TOKEN"] if "WM_TOKEN" in os.environ else ""
9
  GIT_USER = os.environ["GIT_USER"] if "GIT_USER" in os.environ else ""
@@ -89,6 +90,15 @@ def move_file(source: str, destination: str, excludes: list[str] = []):
89
  for file in files:
90
  if file in excludes:
91
  continue
 
 
 
 
 
 
 
 
 
92
  logging.info(f"Moving {file} to {destination}")
93
  # move each file to destination Directory, if it already exists, it will be replaced
94
  shutil.move(f"{source}/{file}", destination)
 
4
  from typing import List, Optional
5
  import logging
6
 
7
+
8
  HF_TOKEN = os.environ["HF_TOKEN"] if "HF_TOKEN" in os.environ else ""
9
  WiseModel_TOKEN = os.environ["WM_TOKEN"] if "WM_TOKEN" in os.environ else ""
10
  GIT_USER = os.environ["GIT_USER"] if "GIT_USER" in os.environ else ""
 
90
  for file in files:
91
  if file in excludes:
92
  continue
93
+ # if file already exists in the destination directory, remove it
94
+ if os.path.exists(f"{destination}/{file}"):
95
+ logging.info(f"Removing {file} from {destination}")
96
+ # incase is a directory, remove it recursively
97
+ if os.path.isdir(f"{destination}/{file}"):
98
+ # force remove the directory and all its contents
99
+ shutil.rmtree(f"{destination}/{file}", ignore_errors=True)
100
+ else:
101
+ os.remove(f"{destination}/{file}")
102
  logging.info(f"Moving {file} to {destination}")
103
  # move each file to destination Directory, if it already exists, it will be replaced
104
  shutil.move(f"{source}/{file}", destination)