mirror of
https://github.com/gurrgur/er-patcher.git
synced 2026-06-13 01:47:52 +00:00
Retry deleting eldenring.exe if it is still running
This commit is contained in:
parent
e9f39e6ae3
commit
adf3fe57aa
1 changed files with 11 additions and 5 deletions
16
er-patcher
16
er-patcher
|
|
@ -8,16 +8,22 @@ import struct
|
|||
import re
|
||||
from shutil import rmtree
|
||||
import os
|
||||
import time
|
||||
|
||||
def cleanup(game_dir_patched):
|
||||
if game_dir_patched.exists():
|
||||
eldenring_path = game_dir_patched / "eldenring.exe"
|
||||
try:
|
||||
if eldenring_path.exists():
|
||||
while eldenring_path.exists():
|
||||
try:
|
||||
os.remove(eldenring_path)
|
||||
rmtree(game_dir_patched)
|
||||
except Exception as e:
|
||||
print(f"er-patcher: could not delete {game_dir_patched}: {e}")
|
||||
break
|
||||
except PermissionError:
|
||||
# eldenring.exe is still running, retry in 3 s
|
||||
time.sleep(3)
|
||||
except Exception as e:
|
||||
print(f"er-patcher: could not delete {eldenring_path}: {e}")
|
||||
break
|
||||
rmtree(game_dir_patched)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue