Skip to content

Commit

Permalink
[Fixes #10130] Data retriever dont assign the folder/file permissions…
Browse files Browse the repository at this point in the history
… correcly (#10131) (#10133)

Co-authored-by: Alessio Fabiani <alessio.fabiani@geosolutionsgroup.com>

Co-authored-by: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com>
Co-authored-by: Alessio Fabiani <alessio.fabiani@geosolutionsgroup.com>
  • Loading branch information
3 people committed Oct 12, 2022
1 parent 4df71f6 commit 0582773
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit 0582773

Please sign in to comment.