fix deleting Recycle Bin files
This commit is contained in:
parent
6098c24227
commit
88b13012aa
4 changed files with 10 additions and 6 deletions
|
@ -847,7 +847,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
if (!curMedia.contains(it)) {
|
if (!curMedia.contains(it)) {
|
||||||
val path = (it as? Medium)?.path
|
val path = (it as? Medium)?.path
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
mMediumDao.deleteMediumPath(path)
|
deleteDBPath(mMediumDao, path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -884,8 +884,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
Thread {
|
Thread {
|
||||||
val useRecycleBin = config.useRecycleBin
|
val useRecycleBin = config.useRecycleBin
|
||||||
filtered.forEach {
|
filtered.forEach {
|
||||||
if (!useRecycleBin) {
|
if (it.path.startsWith(recycleBinPath) || !useRecycleBin) {
|
||||||
mMediumDao.deleteMediumPath(it.path)
|
deleteDBPath(mMediumDao, it.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
|
|
|
@ -193,7 +193,7 @@ fun BaseSimpleActivity.tryDeleteFileDirItem(fileDirItem: FileDirItem, allowDelet
|
||||||
deleteFile(fileDirItem, allowDeleteFolder) {
|
deleteFile(fileDirItem, allowDeleteFolder) {
|
||||||
if (deleteFromDatabase) {
|
if (deleteFromDatabase) {
|
||||||
Thread {
|
Thread {
|
||||||
galleryDB.MediumDao().deleteMediumPath(fileDirItem.path)
|
deleteDBPath(galleryDB.MediumDao(), fileDirItem.path)
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
callback?.invoke(it)
|
callback?.invoke(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ fun Context.rescanFolderMediaSync(path: String) {
|
||||||
if (!newMedia.contains(it)) {
|
if (!newMedia.contains(it)) {
|
||||||
val mediumPath = (it as? Medium)?.path
|
val mediumPath = (it as? Medium)?.path
|
||||||
if (mediumPath != null) {
|
if (mediumPath != null) {
|
||||||
mediumDao.deleteMediumPath(mediumPath)
|
deleteDBPath(mediumDao, mediumPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,7 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
||||||
val mediaToDelete = ArrayList<Medium>()
|
val mediaToDelete = ArrayList<Medium>()
|
||||||
media.filter { !getDoesFilePathExist(it.path) }.forEach {
|
media.filter { !getDoesFilePathExist(it.path) }.forEach {
|
||||||
if (it.path.startsWith(recycleBinPath)) {
|
if (it.path.startsWith(recycleBinPath)) {
|
||||||
mediumDao.deleteMediumPath(it.path.removePrefix(recycleBinPath))
|
deleteDBPath(mediumDao, it.path)
|
||||||
} else {
|
} else {
|
||||||
mediaToDelete.add(it)
|
mediaToDelete.add(it)
|
||||||
}
|
}
|
||||||
|
@ -478,3 +478,7 @@ fun Context.getUpdatedDeletedMedia(mediumDao: MediumDao): ArrayList<Medium> {
|
||||||
}
|
}
|
||||||
return media
|
return media
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.deleteDBPath(mediumDao: MediumDao, path: String) {
|
||||||
|
mediumDao.deleteMediumPath(path.replaceFirst(recycleBinPath, RECYCLE_BIN))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue