Follow-up from "Account Persistence"
The following discussions from !5135 (merged) should be addressed:
-
@ChrisSchinnerl started a discussion: Why would you open the file and assign it to the
am
already? You don't know whether you are in the middle of an upgrade.handleInterruptedUpgrade
should happen before that. Then you know that the file you open is definitely either an old file that needs to be upgraded or a new one. Not a corrupt one. -
@ChrisSchinnerl started a discussion: The convention would be to prefix a compat method with
compatV150CopyAccountsFile
I'd also make this a function and pass in both thesrc
anddst
files and delete/close them in the caller. It's a bit hacky to pass in a file and then recompute its path.It's also a bit confusing to have methods/functions close file handles unless there is a very good reason for it.
-
@ChrisSchinnerl started a discussion: It's not obvious that this would happen in here and that the caller can rely on it. Might be better to have that in a caller with a comment.
-
@ChrisSchinnerl started a discussion: Instead of introducing this helper you could just open the file with os.CREATE and then do
f.Stat()
on the file handler to check if the size is 0.