Skip to content

Commit da001d7

Browse files
committed
better ordering of permission logic
1 parent 61c5c39 commit da001d7

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

conreq/core/base/management/commands/preconfig_conreq.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,20 @@ def recursive_chown(path, uid, gid):
101101
for dirpath, dirnames, filenames in os.walk(path):
102102
try:
103103
shutil.chown(dirpath, new_uid, new_gid)
104-
for filename in filenames:
105-
shutil.chown(os.path.join(dirpath, filename), new_uid, new_gid)
104+
try:
105+
for filename in filenames:
106+
shutil.chown(
107+
os.path.join(dirpath, filename), new_uid, new_gid
108+
)
109+
except FileNotFoundError:
110+
print(
111+
'Unable to apply permissions to "'
112+
+ os.path.join(dirpath, filename)
113+
+ '". File not found.'
114+
)
106115
except PermissionError:
107116
print(
108117
'Unable to apply permissions to "'
109118
+ dirpath
110119
+ '". Permission denied.'
111120
)
112-
except FileNotFoundError:
113-
print(
114-
'Unable to apply permissions to "'
115-
+ dirpath
116-
+ '". File not found.'
117-
)

0 commit comments

Comments
 (0)