File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
core/src/main/java/de/raphaelebner/roomdatabasebackup/core Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -417,13 +417,19 @@ class RoomBackup(var context: Context) {
417417 // Close the database
418418 roomDatabase!! .close()
419419 roomDatabase = null
420+
421+ val bos = BufferedOutputStream (destination)
420422 if (backupIsEncrypted) {
421423 val encryptedBytes = encryptBackup() ? : return
422- destination .write(encryptedBytes)
424+ bos .write(encryptedBytes)
423425 } else {
424426 // Copy current database to save location (/files dir)
425- copy(DATABASE_FILE , destination)
427+ val inputStream = DATABASE_FILE .inputStream().buffered()
428+ inputStream.copyTo(bos)
429+ inputStream.close()
426430 }
431+ bos.flush()
432+ bos.close()
427433
428434 // If maxFileCount is set and is reached, delete oldest file
429435 if (maxFileCount != null ) {
You can’t perform that action at this time.
0 commit comments