Skip to content

Commit

Permalink
Added tmp path to writeable_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Oct 12, 2023
1 parent 72fc321 commit 3654c4d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 1 addition & 3 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@
'es': 'Español',
'fr': 'Français'}


# Paths are implemented operating system independent using pathlib.
# To override them (in instance/production.py) either use them like here
# or use absolute paths like e.g. pathlib.Path('/some/location/somewhere')
FILES_PATH = Path(__file__).parent.parent / 'files'
EXPORT_PATH = Path(FILES_PATH) / 'export'
UPLOAD_PATH = Path(FILES_PATH) / 'uploads'
TMP_PATH = Path('/tmp') # used e.g. for processing imports and export files
TMP_PATH = Path('/tmp') # For processing files e.g. at import and export

# Image processing
DISPLAY_FILE_EXT = ['.bmp', '.gif', '.ico', '.jpeg', '.jpg', '.png', '.svg']
PROCESSABLE_EXT = ['.tiff', '.tif']
PROCESSED_EXT = '.jpeg'

PROCESSED_IMAGE_PATH = Path(FILES_PATH) / 'processed_images'
RESIZED_IMAGES = Path(PROCESSED_IMAGE_PATH) / 'resized'
IMAGE_SIZE = {
Expand Down
11 changes: 4 additions & 7 deletions openatlas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,16 @@ def before_request() -> None:
for file_ in app.config['UPLOAD_PATH'].iterdir():
if file_.stem.isdigit():
g.files[int(file_.stem)] = file_
# Set max file upload in MB
app.config['MAX_CONTENT_LENGTH'] = \
g.settings['file_upload_max_size'] * 1024 * 1024

g.settings['file_upload_max_size'] * 1024 * 1024 # Max upload in MB
g.display_file_ext = app.config['DISPLAY_FILE_EXT']
if g.settings['image_processing']:
g.display_file_ext += app.config['PROCESSABLE_EXT']

g.writable_paths = [
app.config['UPLOAD_PATH'],
app.config['EXPORT_PATH'],
app.config['RESIZED_IMAGES']] # For system checks

app.config['RESIZED_IMAGES'],
app.config['UPLOAD_PATH'],
app.config['TMP_PATH']]
if request.path.startswith('/api/'):
ip = request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
if not current_user.is_authenticated \
Expand Down
1 change: 1 addition & 0 deletions tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def test_index(self) -> None:

g.writable_paths.append(Path(app.root_path) / 'error')
app.config['DATABASE_VERSION'] = 'error'
app.config['EXPORT_PATH'] = Path('error')
rv = self.app.get(url_for('view', id_=666), follow_redirects=True)
assert b'teapot' in rv.data
assert b'OpenAtlas with default password is still' in rv.data
Expand Down

0 comments on commit 3654c4d

Please sign in to comment.