Skip to content

Commit

Permalink
Merge pull request #519 from ganwell/fix_temp_path
Browse files Browse the repository at this point in the history
fix: move temporary path to data directory
  • Loading branch information
Jean-Louis Fuchs authored Aug 22, 2022
2 parents 2f8bda1 + afce2ca commit 0cf779c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ jobs:
run: |
echo "ENV=dev" >> .env
echo "UID=$(id --user)" >> .env
echo "DATABASE_DIR=${{ runner.temp }}/document-merge-service/data" >> .env
echo "MEDIA_ROOT=${{ runner.temp }}/document-merge-service/media" >> .env
- name: Run tests
run: poetry run pytest --no-cov-on-fail --cov --create-db -vv
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG UID=901

RUN wget -q https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -P /usr/local/bin \
&& chmod +x /usr/local/bin/wait-for-it.sh \
&& mkdir -p /app /var/lib/document-merge-service/data /var/lib/document-merge-service/media /var/www/static \
&& mkdir -p /app /var/lib/document-merge-service/data/tmp /var/lib/document-merge-service/media /var/www/static \
&& useradd -u $UID -r document-merge-service --create-home \
&& mkdir /home/document-merge-service/.config \
&& chmod -R 770 /var/lib/document-merge-service/data /var/lib/document-merge-service/media /var/www/static /home/document-merge-service \
Expand Down
2 changes: 1 addition & 1 deletion document_merge_service/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def merge(self, request, pk=None):
convert = serializer.data.get("convert")

if convert:
dir = Path(settings.MEDIA_ROOT, "__convert__")
dir = Path(settings.DATABASE_DIR, "tmp")
dir.mkdir(parents=True, exist_ok=True)
with NamedTemporaryFile("wb", dir=dir) as tmp:
tmp.write(response.content)
Expand Down
5 changes: 2 additions & 3 deletions document_merge_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ def default(default_dev=env.NOTSET, default_prod=env.NOTSET):
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASE_DIR = env.str("DATABASE_DIR", default="/var/lib/document-merge-service/data")
DATABASES = {
"default": {
"ENGINE": env.str("DATABASE_ENGINE", default="django.db.backends.sqlite3"),
"NAME": env.str(
"DATABASE_NAME", default="/var/lib/document-merge-service/data/sqlite3.db"
),
"NAME": env.str("DATABASE_NAME", default=f"{DATABASE_DIR}/sqlite3.db"),
"USER": env.str("DATABASE_USER", default=""),
"PASSWORD": env.str("DATABASE_PASSWORD", default=""),
"HOST": env.str("DATABASE_HOST", default=""),
Expand Down

0 comments on commit 0cf779c

Please sign in to comment.