mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-29 06:37:16 +02:00
Fix:Android allow deleting local library item that doesnt exist on device #105
This commit is contained in:
@@ -196,7 +196,11 @@ class AbsFileSystem : Plugin() {
|
|||||||
if (localLibraryItem?.folderId?.startsWith("internal-") == true) {
|
if (localLibraryItem?.folderId?.startsWith("internal-") == true) {
|
||||||
Log.d(tag, "Deleting internal library item at absolutePath $absolutePath")
|
Log.d(tag, "Deleting internal library item at absolutePath $absolutePath")
|
||||||
val file = File(absolutePath)
|
val file = File(absolutePath)
|
||||||
success = file.deleteRecursively()
|
success = if (file.exists()) {
|
||||||
|
file.deleteRecursively()
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var subfolderPathToDelete = ""
|
var subfolderPathToDelete = ""
|
||||||
localLibraryItem?.folderId?.let { folderId ->
|
localLibraryItem?.folderId?.let { folderId ->
|
||||||
@@ -218,7 +222,12 @@ class AbsFileSystem : Plugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val docfile = DocumentFileCompat.fromUri(mainActivity, Uri.parse(contentUrl))
|
val docfile = DocumentFileCompat.fromUri(mainActivity, Uri.parse(contentUrl))
|
||||||
success = docfile?.delete() == true
|
if (docfile?.exists() == true) {
|
||||||
|
success = docfile.delete() == true
|
||||||
|
} else {
|
||||||
|
Log.d(tag, "Folder $contentUrl doesn't exist")
|
||||||
|
success = true
|
||||||
|
}
|
||||||
|
|
||||||
if (subfolderPathToDelete != "") {
|
if (subfolderPathToDelete != "") {
|
||||||
Log.d(tag, "Deleting empty subfolder at $subfolderPathToDelete")
|
Log.d(tag, "Deleting empty subfolder at $subfolderPathToDelete")
|
||||||
|
|||||||
Reference in New Issue
Block a user