Lock databases during backup export.

pull/1/head
Matthew Chen 8 years ago
parent b77382f99c
commit cb4b44b8f4

@ -188,6 +188,11 @@ NS_ASSUME_NONNULL_BEGIN
backupDirPath:backupDirPath]) { backupDirPath:backupDirPath]) {
return; return;
} }
// Use a read/write transaction to acquire a file lock on the database files.
//
// TODO: If we use multiple database files, lock them too.
[TSStorageManager.sharedManager.newDatabaseConnection
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
if (![self copyDirectory:OWSFileSystem.appDocumentDirectoryPath if (![self copyDirectory:OWSFileSystem.appDocumentDirectoryPath
dstDirName:@"appDocumentDirectoryPath" dstDirName:@"appDocumentDirectoryPath"
backupDirPath:backupDirPath]) { backupDirPath:backupDirPath]) {
@ -198,6 +203,7 @@ NS_ASSUME_NONNULL_BEGIN
backupDirPath:backupDirPath]) { backupDirPath:backupDirPath]) {
return; return;
} }
}];
if (![self zipDirectory:backupDirPath dstFilePath:backupZipPath]) { if (![self zipDirectory:backupDirPath dstFilePath:backupZipPath]) {
return; return;
} }

Loading…
Cancel
Save