Skip to content

Commit

Permalink
Fixes learningequality#3232 (hopefully): handle metadata check when D…
Browse files Browse the repository at this point in the history
…evice is imported.
  • Loading branch information
jamalex authored and benjaoming committed Mar 20, 2015
1 parent cc374bf commit dec433c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python-packages/securesync/devices/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,15 @@ def set_key(self, key):
self.key = key

def get_key(self):
self.key = None
if not self.key:
if self.get_metadata().is_own_device:
self.key = crypto.get_own_key()
elif self.public_key:
try:
if self.get_metadata().is_own_device:
self.key = crypto.get_own_key()
except:
# If device has not yet been saved, but ID is set, then getting metadata may fail (on MySQL)
pass
if not self.key and self.public_key:
self.key = crypto.Key(public_key_string=self.public_key)
return self.key

Expand Down

0 comments on commit dec433c

Please sign in to comment.