Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Apr 4, 2024
1 parent 2756ef6 commit f0db2aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ private void importDatabase(final StoredFileHelper file, final Uri importDataUri
throw new IOException("Could not create databases dir");
}

// replace the current database
if (!manager.extractDb(file)) {
Toast.makeText(requireContext(), R.string.could_not_import_all_files,
Toast.LENGTH_LONG)
Expand Down Expand Up @@ -265,7 +266,7 @@ private void cleanImport(@NonNull final Context context,
}

/**
* Save import path and restart system.
* Save import path and restart app.
*
* @param importDataUri The import path to save
*/
Expand All @@ -290,6 +291,7 @@ private void saveLastImportExportDataUri(final Uri importExportDataUri) {
private void showErrorSnackbar(final Throwable e, final String request) {
ErrorUtil.showSnackbar(this, new ErrorInfo(e, UserAction.DATABASE_IMPORT_EXPORT, request));
}

private void createErrorNotification(final Throwable e, final String request) {
ErrorUtil.createNotification(
requireContext(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
return fileLocator.dbDir.exists() || fileLocator.dbDir.mkdir()
}

/**
* Extracts the database from the given file to the app's database directory.
* The current app's database will be overwritten.
* @param file the .zip file to extract the database from
* @return true if the database was successfully extracted, false otherwise
*/
fun extractDb(file: StoredFileHelper): Boolean {
val success = ZipHelper.extractFileFromZip(
file,
BackupFileLocator.FILE_NAME_DB,
fileLocator.db.path,
file,
BackupFileLocator.FILE_NAME_DB,
fileLocator.db.path,
)

if (success) {
Expand Down

0 comments on commit f0db2aa

Please sign in to comment.