Skip to content

Commit fb88fb2

Browse files
bobo yangbobo yang
authored andcommitted
fix: Improve Windows file deletion handling
- Refactor rmtree function to handle Windows deletion errors - Remove unused shutil imports from multiple files - Add error handling and retry logic for file removal
1 parent 15f6afd commit fb88fb2

File tree

4 files changed

+3
-3
lines changed

4 files changed

+3
-3
lines changed

devchat/_cli/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import List, Optional, Tuple
22

33
import click
4+
45
from devchat.utils import rmtree
56

67

devchat/_cli/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import shutil
32
import sys
43
import zipfile
54
from contextlib import contextmanager

devchat/_service/route/workflows.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import shutil
21
from pathlib import Path
32
from typing import List
43

devchat/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ def openai_response_tokens(message: dict, model: str) -> int:
244244
"""Returns the number of tokens used by a response."""
245245
return openai_message_tokens(message, model)
246246

247+
247248
def rmtree(path: str) -> None:
248249
import shutil
249250

@@ -268,4 +269,4 @@ def __onerror(func, path, _1):
268269
# Retry the function that failed
269270
func(path)
270271

271-
shutil.rmtree(path, onerror=__onerror)
272+
shutil.rmtree(path, onerror=__onerror)

0 commit comments

Comments
 (0)