File.renameTo() fails during a database sync
adrian opened this issue · comments
During a database sync the File.RenameTo() operation fails. At this point the existing database has been deleted.
To fix this issue the code in com._17od.upm.gui.DatabaseActions.replaceDatabase() should be refactored. Rather then simply deleting the local db it should be kept around so that it can be reinstated if there are problems elsewhere with the sync operation.
This problem was originally reported on Sourceforge,
http://sourceforge.net/tracker/?func=detail&aid=3090318&group_id=154394&atid=791607
I found the problem and send a patch to adrian, because I don't know how it works on github.
I think you can close this issue.
I still think we need to refactor this method. While your patch decreases the likelihood of a problem with the rename (now a copy), if there ever was a problem you're still left without a database. Having the delete where it is is just a bit risky.
But if the copy method throws a exception the database won't delete..
So were is the problem?
The problem is that the local database has already been deleted by the time Util.copy() is called. See line 156.
Fixed. See 7e26ee7