Skip to content

Commit 335ab9d

Browse files
author
Andrew Mickael
committed
Fixed permission issue on NT systems when trying to overwrite existing directory
1 parent da6a414 commit 335ab9d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

create_flask_service/Service.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ def __init__(self, service_name: str, root_dir: str):
2626
try:
2727
shutil.rmtree(self.cwd)
2828
except (PermissionError, WindowsError):
29-
os.chmod(self.cwd, stat.S_IWUSR)
29+
for root, dirs, files in os.walk(self.cwd):
30+
for directory in dirs:
31+
os.chmod(os.path.join(root, directory), stat.S_IWUSR)
32+
for file in files:
33+
os.chmod(os.path.join(root, file), stat.S_IWUSR)
3034
shutil.rmtree(self.cwd)
3135
else:
3236
print("Stopping")

create_flask_service/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
__author__ = "Andrew Mickael"
9-
__version__ = "0.1.2"
9+
__version__ = "0.1.3"
1010
__description__ = "Create a Flask microservice with a few keystrokes"
1111

1212

0 commit comments

Comments
 (0)