From 9b2a419d9b882d0c7251de4a257e156f31ffb376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 24 Aug 2016 11:33:02 +0200 Subject: [PATCH] Extra debug logging for file uploads --- pillar/api/file_storage.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pillar/api/file_storage.py b/pillar/api/file_storage.py index 902d8fcd..0a19f2fb 100644 --- a/pillar/api/file_storage.py +++ b/pillar/api/file_storage.py @@ -683,6 +683,10 @@ def stream_to_gcs(project_id): else: # Upload the file to GCS. from gcloud.streaming import transfer + + log.debug('Streaming file to GCS bucket; id=%s, fname=%s, size=%i', + file_id, internal_fname, file_size) + # Files larger than this many bytes will be streamed directly from disk, smaller # ones will be read into memory and then uploaded. transfer.RESUMABLE_UPLOAD_THRESHOLD = 102400 @@ -702,19 +706,24 @@ def stream_to_gcs(project_id): # Reload the blob to get the file size according to Google. blob.reload() + + log.debug('Marking uploaded file id=%s, fname=%s, size=%i as "queued_for_processing"', + file_id, internal_fname, blob.size) update_file_doc(file_id, status='queued_for_processing', file_path=internal_fname, length=blob.size, content_type=uploaded_file.mimetype) + log.debug('Processing uploaded file id=%s, fname=%s, size=%i', file_id, internal_fname, blob.size) process_file(gcs, file_id, local_file) # Local processing is done, we can close the local file so it is removed. if local_file is not None: local_file.close() - log.debug('Handled uploaded file id=%s, fname=%s, size=%i', file_id, internal_fname, blob.size) + log.debug('Handled uploaded file id=%s, fname=%s, size=%i, status=%i', + file_id, internal_fname, blob.size, status) # Status is 200 if the file already existed, and 201 if it was newly created. # TODO: add a link to a thumbnail in the response. @@ -791,6 +800,9 @@ def create_file_doc_for_upload(project_id, uploaded_file): status, file_fields) raise wz_exceptions.InternalServerError() + log.debug('Created file document %s for uploaded file %s; internal name %s', + file_fields['_id'], uploaded_file.filename, internal_filename) + return file_fields['_id'], internal_filename, status