aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/submit
diff options
context:
space:
mode:
authorBoris Bobrov <breton@cynicmansion.ru>2014-07-27 07:25:14 +0400
committerBoris Bobrov <breton@cynicmansion.ru>2015-02-16 13:41:09 +0300
commit54b4b28f84444a5b4e95eca0c2ca6429d52573c3 (patch)
treea9b93e8af396a5dfc150dfc2ee929885d5535935 /mediagoblin/submit
parent067ee131885c2c3df88cb75e1c41a33d6681752f (diff)
downloadmediagoblin-54b4b28f84444a5b4e95eca0c2ca6429d52573c3.tar.lz
mediagoblin-54b4b28f84444a5b4e95eca0c2ca6429d52573c3.tar.xz
mediagoblin-54b4b28f84444a5b4e95eca0c2ca6429d52573c3.zip
Add new hook for two-step media type checking
Before uploaded media files were checked by extension. This led to situations when a plugin can support file with specific extension but doesn't due to lack of codecs, for example. Since the plugin reported that it supports uploaded file type, the upload was being declared successful, but transcoding failed. The failures were not easy to debug. The change adds a new hook that could allow two-step checking of the content. The result of the hook execution returns a tuple with media type name, manager and a callable sniffer, that can be used to perform probably expensive checks of the content. Also the change adds implementation of the hook for video.
Diffstat (limited to 'mediagoblin/submit')
-rw-r--r--mediagoblin/submit/views.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
index b0588599..ccdd70bc 100644
--- a/mediagoblin/submit/views.py
+++ b/mediagoblin/submit/views.py
@@ -29,8 +29,7 @@ from mediagoblin.tools.response import render_to_response, redirect
from mediagoblin.decorators import require_active_login, user_has_privilege
from mediagoblin.submit import forms as submit_forms
from mediagoblin.messages import add_message, SUCCESS
-from mediagoblin.media_types import \
- InvalidFileType, FileTypeNotSupported
+from mediagoblin.media_types import FileTypeNotSupported
from mediagoblin.submit.lib import \
check_file_field, submit_media, get_upload_file_limits, \
FileUploadLimit, UserUploadLimit, UserPastUploadLimit
@@ -89,18 +88,10 @@ def submit_start(request):
_('Sorry, you have reached your upload limit.'))
return redirect(request, "mediagoblin.user_pages.user_home",
user=request.user.username)
-
+ except FileTypeNotSupported as e:
+ submit_form.file.errors.append(e)
except Exception as e:
- '''
- This section is intended to catch exceptions raised in
- mediagoblin.media_types
- '''
- if isinstance(e, InvalidFileType) or \
- isinstance(e, FileTypeNotSupported):
- submit_form.file.errors.append(
- e)
- else:
- raise
+ raise
return render_to_response(
request,