catch all exceptions at toggling favorites

This commit is contained in:
tibbi 2021-10-24 18:35:31 +02:00
parent ee124506e8
commit 352dbe40bf
1 changed files with 6 additions and 6 deletions

View File

@ -847,14 +847,14 @@ fun Context.getFavoritePaths(): ArrayList<String> {
fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFilenameFromPath(), path.getParentPath()) fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFilenameFromPath(), path.getParentPath())
fun Context.updateFavorite(path: String, isFavorite: Boolean) { fun Context.updateFavorite(path: String, isFavorite: Boolean) {
if (isFavorite) { try {
try { if (isFavorite) {
favoritesDB.insert(getFavoriteFromPath(path)) favoritesDB.insert(getFavoriteFromPath(path))
} catch (e: Exception) { } else {
toast(R.string.unknown_error_occurred) favoritesDB.deleteFavoritePath(path)
} }
} else { } catch (e: Exception) {
favoritesDB.deleteFavoritePath(path) toast(R.string.unknown_error_occurred)
} }
} }