catch some exceptions at inserting folders in db

This commit is contained in:
tibbi 2020-05-04 10:14:55 +02:00
parent e7174f9001
commit 8bbc498724

View file

@ -425,7 +425,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun checkDefaultSpamFolders() { private fun checkDefaultSpamFolders() {
if (!config.spamFoldersChecked) { if (!config.spamFoldersChecked) {
val spamFolders = arrayListOf( val spamFolders = arrayListOf(
"/storage/emulated/0/Android/data/com.facebook.orca/files/stickers" "/storage/emulated/0/Android/data/com.facebook.orca/files/stickers"
) )
val OTGPath = config.OTGPath val OTGPath = config.OTGPath
@ -1030,16 +1030,17 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
val newDir = createDirectoryFromMedia(folder, newMedia, albumCovers, hiddenString, includedFolders, getProperFileSize) val newDir = createDirectoryFromMedia(folder, newMedia, albumCovers, hiddenString, includedFolders, getProperFileSize)
dirs.add(newDir) dirs.add(newDir)
setupAdapter(dirs) setupAdapter(dirs)
try {
// make sure to create a new thread for these operations, dont just use the common bg thread // make sure to create a new thread for these operations, dont just use the common bg thread
Thread { Thread {
try {
directoryDao.insert(newDir) directoryDao.insert(newDir)
if (folder != RECYCLE_BIN) { if (folder != RECYCLE_BIN) {
mediaDB.insertAll(newMedia) mediaDB.insertAll(newMedia)
} }
}.start() } catch (ignored: Exception) {
} catch (ignored: Exception) { }
} }.start()
} }
mLoadedInitialPhotos = true mLoadedInitialPhotos = true
@ -1213,7 +1214,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun getCurrentlyDisplayedDirs() = getRecyclerAdapter()?.dirs ?: ArrayList() private fun getCurrentlyDisplayedDirs() = getRecyclerAdapter()?.dirs ?: ArrayList()
private fun getBubbleTextItem(index: Int) = getRecyclerAdapter()?.dirs?.getOrNull(index)?.getBubbleText(config.directorySorting, this, mDateFormat, mTimeFormat) private fun getBubbleTextItem(index: Int) = getRecyclerAdapter()?.dirs?.getOrNull(index)?.getBubbleText(config.directorySorting, this, mDateFormat, mTimeFormat)
?: "" ?: ""
private fun setupLatestMediaId() { private fun setupLatestMediaId() {
ensureBackgroundThread { ensureBackgroundThread {