yahoo / squidb

SquiDB is a SQLite database library for Android and iOS
https://github.com/yahoo/squidb/wiki
Apache License 2.0
1.31k stars 132 forks source link

Fix copyDatabase method #233

Closed sbosley closed 7 years ago

sbosley commented 7 years ago

SquidUtilities.copyDatabase never quite worked correctly. The two major problems were that 1) it never copied the supporting files like the journal or WAL file, meaning if the DB hadn't been checkpointed after a transaction the main file might not have the changes yet, and 2) to be really safe, the exclusive lock should be acquired while copying the file so that no other thread could do anything to the DB while it was being copied. This PR fixes these shortcomings by moving copyDatabase into SquidDatabase itself, deprecating the SquidUtilities version, and ensuring that the method is covered in our test suite.

jdkoren commented 7 years ago

LGTM