Make writing keys.dat safer by creating a backup file #715

Merged
yurivict merged 3 commits from some_small_changes into master 2014-12-26 03:09:17 +01:00
yurivict commented 2014-09-15 09:01:08 +02:00 (Migrated from github.com)

Just overwriting the file may cause its loss in case the overall disk write operation fails in the middle.
Created a .bak file for the duration of the write operation to prevent such possible file loss.

Just overwriting the file may cause its loss in case the overall disk write operation fails in the middle. Created a .bak file for the duration of the write operation to prevent such possible file loss.
ghost commented 2014-09-15 18:45:43 +02:00 (Migrated from github.com)

Your changes nicely show how much unnecessary repeated code is left in Bitmessage.

Your changes nicely show how much unnecessary repeated code is left in Bitmessage.
yurivict commented 2014-09-16 19:09:40 +02:00 (Migrated from github.com)

Yes, a lot of code duplication.

keys.dat contains keys for your accounts, that's why it should be very well protected. I also added timestamp on the backup file now because otherwise it can be overwritten too.

I just noticed another bad problem that errors from shared.writeKeysFile() not propagate to the user level and are silently ignored. I think error propagation is broken in bitmessage in general. Any important error during execution (like this one) should be shown to the user, and now they are only printed in the stdout or stderr where nobody is looking.

This PR is good anyways, just need further improvement.

Yes, a lot of code duplication. keys.dat contains keys for your accounts, that's why it should be very well protected. I also added timestamp on the backup file now because otherwise it can be overwritten too. I just noticed another bad problem that errors from shared.writeKeysFile() not propagate to the user level and are silently ignored. I think error propagation is broken in bitmessage in general. Any important error during execution (like this one) should be shown to the user, and now they are only printed in the stdout or stderr where nobody is looking. This PR is good anyways, just need further improvement.
This repo is archived. You cannot comment on pull requests.
No description provided.