From fc682361b6d34052fb59b17ba2a3d71a3a6f6650 Mon Sep 17 00:00:00 2001 From: Ian Weller Date: Mon, 21 Dec 2009 20:28:39 -0600 Subject: [PATCH 1/1] Fixes to Metadir:pages_add_rev --- src/mw/metadir.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mw/metadir.py b/src/mw/metadir.py index 49a91cf..3988d78 100644 --- a/src/mw/metadir.py +++ b/src/mw/metadir.py @@ -82,11 +82,13 @@ class Metadir(object): def pages_add_rev(self, pageid, rv): pagefile = os.path.join(self.location, 'cache', 'pages', str(pageid)) fd = file(pagefile, 'w+') - pagedata = json.loads(fd.read()) + pagedata_raw = fd.read() + if pagedata_raw == '': + pagedata = {} + else: + pagedata = json.loads(pagedata_raw) rvid = int(rv['revid']) - if pageid not in pagedata.keys(): - pagedata[pageid] = {} - pagedata[pageid][rvid] = { + pagedata[rvid] = { 'user': rv['user'], 'timestamp': rv['timestamp'], 'content': rv['*'], } -- 2.39.5