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

[Fixes #10130] Data retriever dont assign the folder/file permissions… #10131

Merged
merged 2 commits into from
Oct 12, 2022
Merged
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions geonode/storage/data_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def file_chunks_iterable(file, chunk_size=None):
with open(self.file_path, "wb") as tmp_file, smart_open.open(uri=self._original_file_uri, mode="rb") as original_file:
for chunk in file_chunks_iterable(original_file):
tmp_file.write(chunk)

except Exception as e:
logger.error(e)
raise DataRetrieverExcepion(detail=e)
Expand Down Expand Up @@ -158,12 +159,18 @@ def transfer_remote_files(self):
for name, data_item_retriever in self.data_items.items():
file_path = data_item_retriever.transfer_remote_file(self.temporary_folder)
self.file_paths[name] = Path(file_path)
os.chmod(file_path, settings.FILE_UPLOAD_PERMISSIONS)
'''
Is more usefull to have always unzipped file than the zip file
So in case is a zip_file, we unzip it and than delete it
'''
if zipfile.is_zipfile(self.file_paths.get('base_file', 'not_zip')):
self._unzip(zip_name=self.file_paths.get('base_file'))

if settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS is not None:
# value is always set by default as None
# https://docs.djangoproject.com/en/3.2/ref/settings/#file-upload-directory-permissions
os.chmod(self.temporary_folder, settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS)
return self.file_paths

def get_paths(self, allow_transfer=False):
Expand Down