Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle read-only directory on Windows #95

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion readmeai/services/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import os
import stat
import platform
import shutil
from enum import Enum
Expand Down Expand Up @@ -94,10 +95,13 @@ async def clone_repository(repository: str, temp_dir: str) -> str:

async def remove_hidden_contents(directory: Path) -> None:
"""Remove hidden files and directories from a specified directory."""
def delete(func, path, execinfo):
os.chmod(path, stat.S_IWUSR)
func(path)
for item in directory.iterdir():
if item.name.startswith(".") and item.name != ".github":
if item.is_dir():
shutil.rmtree(item)
shutil.rmtree(item, onerror=delete)
else:
item.unlink()

Expand Down