Skip to content

Commit c2a610a

Browse files
committed
added clear destination before copy
1 parent 17572b2 commit c2a610a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

gitccpy.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@
3737

3838
copied_count = 0
3939

40+
def clear_destination(folder):
41+
for filename in os.listdir(folder):
42+
file_path = os.path.join(folder, filename)
43+
try:
44+
if os.path.isfile(file_path) or os.path.islink(file_path):
45+
os.unlink(file_path)
46+
elif os.path.isdir(file_path):
47+
shutil.rmtree(file_path)
48+
except Exception as e:
49+
print('Failed to delete %s. Reason: %s' % (file_path, e))
50+
4051
def cp(from_path, to_path):
4152
if not os.path.isfile(from_path): return
4253
os.makedirs(os.path.dirname(to_path), exist_ok=True)
@@ -65,7 +76,10 @@ def copy_paths(paths):
6576

6677
if result.returncode == 0:
6778
paths = result.stdout.splitlines()
79+
80+
clear_destination(CONFIGS['DESTINATION_PATH'])
6881
copy_paths(paths)
82+
6983
if copied_count == 0:
7084
print('No changes in ', CONFIGS['LOCAL_PREXFIX'])
7185
else:

0 commit comments

Comments
 (0)