From 26d5fef4fdd98423efae7437cd1a6d542308e8db Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 17 Jul 2018 13:56:22 +0200 Subject: [PATCH] make sure copyRecursively works at moving paths in recycle bin --- app/build.gradle | 2 +- .../com/simplemobiletools/gallery/extensions/Activity.kt | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8722da5bc..f0d83d742 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -47,7 +47,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:4.4.24' + implementation 'com.simplemobiletools:commons:4.4.27' implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0' implementation 'com.android.support:multidex:1.0.3' implementation 'it.sephiroth.android.exif:library:1.0.1' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt index ff28bb642..ade2a494c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt @@ -201,14 +201,16 @@ fun BaseSimpleActivity.tryDeleteFileDirItem(fileDirItem: FileDirItem, allowDelet fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList, callback: ((wasSuccess: Boolean) -> Unit)?) { Thread { + val mediumDao = galleryDB.MediumDao() var pathsCnt = paths.size paths.forEach { val file = File(it) val internalFile = File(filesDir, it) try { - file.copyRecursively(internalFile, true) - galleryDB.MediumDao().updateDeleted(it, System.currentTimeMillis()) - pathsCnt-- + if (file.copyRecursively(internalFile, true)) { + mediumDao.updateDeleted(it, System.currentTimeMillis()) + pathsCnt-- + } } catch (ignored: Exception) { } }