mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge pull request #715 from rost314/fix_nfs_write_check
fix writable check for NFS mounts
This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| import os | import os | ||||||
| import shutil | import shutil | ||||||
|  | import stat | ||||||
|  |  | ||||||
| from django.conf import settings | from django.conf import settings | ||||||
| from django.core.checks import Error, Warning, register | from django.core.checks import Error, Warning, register | ||||||
| @@ -16,16 +17,25 @@ writeable_hint = ( | |||||||
| def path_check(var, directory): | def path_check(var, directory): | ||||||
|     messages = [] |     messages = [] | ||||||
|     if directory: |     if directory: | ||||||
|         if not os.path.exists(directory): |         if not os.path.isdir(directory): | ||||||
|             messages.append(Error( |             messages.append(Error( | ||||||
|                 exists_message.format(var), |                 exists_message.format(var), | ||||||
|                 exists_hint.format(directory) |                 exists_hint.format(directory) | ||||||
|             )) |             )) | ||||||
|         elif not os.access(directory, os.W_OK | os.X_OK): |         else: | ||||||
|             messages.append(Warning( |             test_file = os.path.join(directory, '__paperless_write_test__') | ||||||
|                 writeable_message.format(var), |             try: | ||||||
|                 writeable_hint.format(directory) |                 open(test_file, 'w') | ||||||
|             )) |             except PermissionError: | ||||||
|  |                 messages.append(Error( | ||||||
|  |                     writeable_message.format(var), | ||||||
|  |                     writeable_hint.format( | ||||||
|  |                         f'\n{stat.filemode(os.stat(directory).st_mode)} ' | ||||||
|  |                         f'{directory}\n') | ||||||
|  |                 )) | ||||||
|  |             else: | ||||||
|  |                 os.remove(test_file) | ||||||
|  |  | ||||||
|     return messages |     return messages | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler