From a625c95f34004385f421b11529c68abb7339d7e9 Mon Sep 17 00:00:00 2001 From: kirbylife Date: Fri, 18 Dec 2020 17:46:02 -0600 Subject: [PATCH] wait to the file is closed before to remove (Windows) --- client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client.py b/client.py index 5ac4e01..86f77f0 100755 --- a/client.py +++ b/client.py @@ -204,7 +204,13 @@ class MunyalClient(Icon): f.write(base64.b85decode(data["file"].encode("ascii"))) os.rename(temp_dir, full_path) else: - os.remove(full_path) + while True: + try: + os.remove(full_path) + break + except: + print("Maybe the file is open, please close first") + sleep(5) else: if data["action"] == "add": os.mkdir(full_path)