Cast file_id to ObjectIf before query

This commit is contained in:
2016-02-22 17:41:38 +01:00
parent 4dbd804307
commit 724a819593

View File

@@ -2,6 +2,7 @@ import os
import time import time
import datetime import datetime
import bugsnag import bugsnag
from bson import ObjectId
from gcloud.storage.client import Client from gcloud.storage.client import Client
from gcloud.exceptions import NotFound from gcloud.exceptions import NotFound
from oauth2client.client import SignedJwtAssertionCredentials from oauth2client.client import SignedJwtAssertionCredentials
@@ -167,7 +168,7 @@ def update_file_name(item):
def _update_name(item, file_id): def _update_name(item, file_id):
files_collection = app.data.driver.db['files'] files_collection = app.data.driver.db['files']
f = files_collection.find_one({'_id': file_id}) f = files_collection.find_one({'_id': ObjectId(file_id)})
status = item['properties']['status'] status = item['properties']['status']
if f and f['backend'] == 'gcs' and status != 'processing': if f and f['backend'] == 'gcs' and status != 'processing':
# Process only files that are on GCS and that are not processing # Process only files that are on GCS and that are not processing