catching some exceptions thrown related to handling cache db

This commit is contained in:
tibbi 2019-02-26 22:17:37 +01:00
parent c64fe82c02
commit e7624ea7d7
2 changed files with 13 additions and 5 deletions

View file

@ -917,11 +917,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
setupAdapter(dirs) setupAdapter(dirs)
try { try {
mDirectoryDao.insert(newDir) mDirectoryDao.insert(newDir)
} catch (ignored: Exception) {
}
if (folder != RECYCLE_BIN) { if (folder != RECYCLE_BIN) {
mMediumDao.insertAll(newMedia) mMediumDao.insertAll(newMedia)
} }
} catch (ignored: Exception) {
}
} }
mLoadedInitialPhotos = true mLoadedInitialPhotos = true

View file

@ -592,7 +592,10 @@ fun Context.removeInvalidDBDirectories(dirs: ArrayList<Directory>? = null, direc
fun Context.updateDBMediaPath(oldPath: String, newPath: String) { fun Context.updateDBMediaPath(oldPath: String, newPath: String) {
val newFilename = newPath.getFilenameFromPath() val newFilename = newPath.getFilenameFromPath()
val newParentPath = newPath.getParentPath() val newParentPath = newPath.getParentPath()
try {
galleryDB.MediumDao().updateMedium(oldPath, newParentPath, newFilename, newPath) galleryDB.MediumDao().updateMedium(oldPath, newParentPath, newFilename, newPath)
} catch (ignored: Exception) {
}
} }
fun Context.updateDBDirectory(directory: Directory, directoryDao: DirectoryDao) { fun Context.updateDBDirectory(directory: Directory, directoryDao: DirectoryDao) {
@ -609,7 +612,12 @@ fun Context.getFavoritePaths(): ArrayList<String> {
// remove the "recycle_bin" from the file path prefix, replace it with real bin path /data/user... // remove the "recycle_bin" from the file path prefix, replace it with real bin path /data/user...
fun Context.getUpdatedDeletedMedia(mediumDao: MediumDao): ArrayList<Medium> { fun Context.getUpdatedDeletedMedia(mediumDao: MediumDao): ArrayList<Medium> {
val media = mediumDao.getDeletedMedia() as ArrayList<Medium> val media = try {
mediumDao.getDeletedMedia() as ArrayList<Medium>
} catch (ignored: Exception) {
ArrayList<Medium>()
}
media.forEach { media.forEach {
it.path = File(recycleBinPath, it.path.removePrefix(RECYCLE_BIN)).toString() it.path = File(recycleBinPath, it.path.removePrefix(RECYCLE_BIN)).toString()
} }