Skip to content

Commit

Permalink
Fix:Android allow deleting local library item that doesnt exist on de…
Browse files Browse the repository at this point in the history
…vice #105
  • Loading branch information
advplyr committed Nov 4, 2024
1 parent 38bb5af commit a163a6a
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ class AbsFileSystem : Plugin() {
if (localLibraryItem?.folderId?.startsWith("internal-") == true) {
Log.d(tag, "Deleting internal library item at absolutePath $absolutePath")
val file = File(absolutePath)
success = file.deleteRecursively()
success = if (file.exists()) {
file.deleteRecursively()
} else {
true
}
} else {
var subfolderPathToDelete = ""
localLibraryItem?.folderId?.let { folderId ->
Expand All @@ -218,7 +222,12 @@ class AbsFileSystem : Plugin() {
}

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 != "") {
Log.d(tag, "Deleting empty subfolder at $subfolderPathToDelete")
Expand Down

0 comments on commit a163a6a

Please sign in to comment.