Make sure size calculations take jsonification into account.
Review URL: https://codereview.chromium.org/188683008
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/chromium-build@255419 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/app.py b/app.py
index 9c2a4f1..a00b12d 100644
--- a/app.py
+++ b/app.py
@@ -118,7 +118,6 @@
logging.debug('content for %s found in blobstore' % localpath)
blob_reader = blobstore.BlobReader(page.content_blob)
page_data['content_blob'] = True
- put_data_into_cache(localpath, page_data)
page_data['content'] = blob_reader.read().decode('utf-8', 'replace')
else:
logging.debug('content for %s found in datastore' % localpath)
@@ -140,7 +139,8 @@
logging.debug('save_page: content was already in unicode')
logging.debug('save_page: content size is %d' % len(content))
# Save to blobstore if content + metadata is too big.
- if len(content.encode('utf-8')) >= 10**6 - 10**5:
+ json_data = json.dumps(content.encode('utf-8'), default=dtdumper)
+ if len(json_data) >= 10**6 - 10**5:
logging.debug('save_page: saving to blob')
content_blob_key = write_blob(content, path_to_mime_type(localpath))
content = None