diff --git a/accounting/storage/ledgercli.py b/accounting/storage/ledgercli.py index 919d8f722d6e62d0455c9e84097dc76aae2cec60..eb864453c9bf2e93ed2a5dc0a2340cb69deda96e 100644 --- a/accounting/storage/ledgercli.py +++ b/accounting/storage/ledgercli.py @@ -173,6 +173,18 @@ class Ledger(Storage): with open(self.ledger_file, 'ab') as f: f.write(output) + # Check to see that no errors were introduced + try: + self.get_transactions() + except AccountingException as exc: + # TODO: Do a hard reset on the repository using Repository.reset, + # this is on hold because of + # https://github.com/libgit2/pygit2/issues/271. + # This solution will work in the meantime + self.delete_transaction(transaction.id) + setattr(exc, 'transaction', transaction) + raise exc + self.commit_changes('Added transaction %s' % transaction.id) _log.info('Added transaction %s', transaction.id)