Skip to content
Snippets Groups Projects
Commit d7f78e1a authored by inso's avatar inso
Browse files

Fixed a bug in history table + versionned cache

parent ddb2361d
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,10 @@ import logging
import json
import tarfile
from cutecoin.core import config
from cutecoin.tools.exceptions import NameAlreadyExists, BadAccountFile
from cutecoin.core.account import Account
from . import config
from ..tools.exceptions import NameAlreadyExists, BadAccountFile
from .account import Account
from .. import __version__
class Application(object):
......@@ -90,7 +91,10 @@ class Application(object):
if os.path.exists(wallet_path):
with open(wallet_path, 'r') as json_data:
data = json.load(json_data)
wallet.load_caches(data)
if 'version' in data and data['version'] == __version__:
wallet.load_caches(data)
else:
os.remove(wallet_path)
for community in account.communities:
wallet.refresh_cache(community)
......@@ -112,7 +116,9 @@ class Application(object):
wallet_path = os.path.join(config.parameters['home'],
account.name, '__cache__', wallet.pubkey)
with open(wallet_path, 'w') as outfile:
json.dump(wallet.jsonify_caches(), outfile, indent=4, sort_keys=True)
data = wallet.jsonify_caches()
data['version'] = __version__
json.dump(data, outfile, indent=4, sort_keys=True)
def import_account(self, file, name):
with tarfile.open(file, "r") as tar:
......
......@@ -27,6 +27,7 @@ class Cache():
self.tx_received = []
self.tx_sent = []
self.awaiting_tx = []
logging.debug(data)
data_received = data['received']
for r in data_received:
......@@ -164,8 +165,9 @@ class Wallet(object):
def load_caches(self, json_data):
for currency in json_data:
self.caches[currency] = Cache(self)
self.caches[currency].load_from_json(json_data[currency])
if currency != 'version':
self.caches[currency] = Cache(self)
self.caches[currency].load_from_json(json_data[currency])
def jsonify_caches(self):
data = {}
......
......@@ -208,7 +208,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
copy_pubkey.triggered.connect(self.copy_pubkey_to_clipboard)
copy_pubkey.setData(person)
menu.addAction(copy_pubkey)
menu.addAction(copy_pubkey)
# Show the context menu.
menu.exec_(self.table_history.mapToGlobal(point))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment