From 4534e5e05e812d12f680067c4bf2477ddd07ef99 Mon Sep 17 00:00:00 2001 From: Brian Simpson Date: Sun, 26 Jan 2014 07:24:02 -0500 Subject: [PATCH] CommentTree migration: handle permacache entries without num_children. --- r2/r2/models/comment_tree.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/r2/r2/models/comment_tree.py b/r2/r2/models/comment_tree.py index e7aa11214..2638a95f6 100644 --- a/r2/r2/models/comment_tree.py +++ b/r2/r2/models/comment_tree.py @@ -329,7 +329,16 @@ class CommentTreeStorageV1(CommentTreeStorageBase): r = g.permacache.get(key) if not r: return None - cids, cid_tree, depth, num_children = r + + try: + cids, cid_tree, depth, num_children = r + except ValueError: + # We got the new version that doesn't include num_children. Make + # a dummy num_children, which will be safe because it's not getting + # used anywhere. + cids, cid_tree, depth = r + num_children = {} + parents = g.permacache.get(p_key) if parents is None: parents = {}