Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

fixes the docker build. also: proper 404 for missing documents/thumbnails

Jonas Winklerd3980303963f
diff --git a/Dockerfile b/Dockerfile
index 1253e3194..82b552b95 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,7 +10,7 @@ COPY src-ui/package* ./
RUN npm install
COPY src-ui .
-RUN node_modules/.bin/ng build --prod --output-hashing none --sourceMap=false
+RUN node_modules/.bin/ng build --prod --output-hashing none --sourceMap=false --output-path dist/paperless-ui
###############################################################################
### Back end ###
diff --git a/src/documents/views.py b/src/documents/views.py
index 166806d8e..997d03213 100755
--- a/src/documents/views.py
+++ b/src/documents/views.py
@@ -1,5 +1,5 @@
from django.db.models import Count, Max
-from django.http import HttpResponse, HttpResponseBadRequest
+from django.http import HttpResponse, HttpResponseBadRequest, Http404
from django.views.decorators.cache import cache_control
from django.views.generic import TemplateView
from django_filters.rest_framework import DjangoFilterBackend
@@ -140,17 +140,27 @@ class DocumentViewSet(RetrieveModelMixin,
@action(methods=['get'], detail=True)
def preview(self, request, pk=None):
- response = self.file_response(pk, "inline")
- return response
+ try:
+ response = self.file_response(pk, "inline")
+ return response
+ except FileNotFoundError:
+ raise Http404("Document source file does not exist")
@action(methods=['get'], detail=True)
@cache_control(public=False, max_age=315360000)
def thumb(self, request, pk=None):
- return HttpResponse(Document.objects.get(id=pk).thumbnail_file, content_type='image/png')
+ try:
+ return HttpResponse(Document.objects.get(id=pk).thumbnail_file, content_type='image/png')
+ except FileNotFoundError:
+ raise Http404("Document thumbnail does not exist")
@action(methods=['get'], detail=True)
def download(self, request, pk=None):
- return self.file_response(pk, "attachment")
+ try:
+ return self.file_response(pk, "attachment")
+ except FileNotFoundError:
+ raise Http404("Document source file does not exist")
+
class LogViewSet(ReadOnlyModelViewSet):