Only set keys in migration if they exist

This commit is contained in:
James Allen 2016-07-08 11:45:36 +01:00
parent bd392f5682
commit 4f34cb7363

View file

@ -130,12 +130,15 @@ module.exports = RedisManager =
return callback(error) if error?
[lines, version, ops, project_id] = results
multi = rclient.multi()
multi.set keys.docLines(doc_id:doc_id), lines
multi.set keys.docVersion(doc_id:doc_id), version
if lines?
multi.set keys.docLines(doc_id:doc_id), lines
if version?
multi.set keys.docVersion(doc_id:doc_id), version
multi.del keys.docOps(doc_id:doc_id)
if ops.length > 0
multi.rpush keys.docOps(doc_id:doc_id), ops...
multi.set keys.projectKey(doc_id:doc_id), project_id
if project_id?
multi.set keys.projectKey(doc_id:doc_id), project_id
multi.exec (error) ->
return callback(error) if error?
return callback null, project_id