mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
fix #1668, properly delete empty folders when appropriate
This commit is contained in:
parent
fbb20477d6
commit
6234050c7f
3 changed files with 10 additions and 2 deletions
|
@ -592,6 +592,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
folders.filter { !getDoesFilePathExist(it.absolutePath, OTGPath) }.forEach {
|
||||
mDirectoryDao.deleteDirPath(it.absolutePath)
|
||||
}
|
||||
|
||||
if (config.deleteEmptyFolders) {
|
||||
folders.filter { !it.absolutePath.isDownloadsFolder() && it.isDirectory && it.toFileDirItem(this).getProperFileCount(this, true) == 0 }.forEach {
|
||||
tryDeleteFileDirItem(it.toFileDirItem(this), true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simplemobiletools.gallery.pro.extensions
|
||||
|
||||
import android.os.Environment
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
|
||||
fun FileDirItem.isDownloadsFolder() = path.equals(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString(), true)
|
||||
fun FileDirItem.isDownloadsFolder() = path.isDownloadsFolder()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simplemobiletools.gallery.pro.extensions
|
||||
|
||||
import android.media.MediaMetadataRetriever
|
||||
import android.os.Environment
|
||||
import com.simplemobiletools.commons.extensions.doesThisOrParentHaveNoMedia
|
||||
import com.simplemobiletools.commons.helpers.NOMEDIA
|
||||
import java.io.File
|
||||
|
@ -70,3 +71,5 @@ fun String.getVideoDuration(): Int {
|
|||
}
|
||||
return seconds
|
||||
}
|
||||
|
||||
fun String.isDownloadsFolder() = equals(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString(), true)
|
||||
|
|
Loading…
Reference in a new issue