mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
fixed the write permission check
This commit is contained in:
parent
8e1a9dde05
commit
1d27a3a14b
@ -23,9 +23,12 @@ def path_check(var, directory):
|
||||
exists_hint.format(directory)
|
||||
))
|
||||
else:
|
||||
test_file = os.path.join(directory, '__paperless_write_test__')
|
||||
test_file = os.path.join(
|
||||
directory, f'__paperless_write_test_{os.getpid()}__'
|
||||
)
|
||||
try:
|
||||
open(test_file, 'w')
|
||||
with open(test_file, 'w'):
|
||||
pass
|
||||
except PermissionError:
|
||||
messages.append(Error(
|
||||
writeable_message.format(var),
|
||||
@ -33,8 +36,9 @@ def path_check(var, directory):
|
||||
f'\n{stat.filemode(os.stat(directory).st_mode)} '
|
||||
f'{directory}\n')
|
||||
))
|
||||
else:
|
||||
os.remove(test_file)
|
||||
finally:
|
||||
if os.path.isfile(test_file):
|
||||
os.remove(test_file)
|
||||
|
||||
return messages
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user