Skip to content

Commit

Permalink
chore: fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
loggerz committed Dec 20, 2024
1 parent a3a5e04 commit 1a94034
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,26 @@ constructor(
result.invokeOnCompletion {
when (it) {
null -> {
ret.completeExceptionally(it)
ret.complete(result.getCompleted())
_documentUri.value = result.getCompleted()
Log.d("DocumentViewModel", "Document retrieved as ${result.getCompleted()}")
}
is DocumentsManager.FileCreationException -> {
Log.i(
"DocumentViewModel",
"Failed to create document file in same directory. Re-asking permission")
ret.complete(result.getCompleted())
ret.completeExceptionally(it)
resetSaveDocumentFolder().invokeOnCompletion { _needReload.value = true }
}
else -> Log.e("DocumentViewModel", "Failed to download document", it)
else -> {
Log.e("DocumentViewModel", "Failed to download document", it)
ret.completeExceptionally(it)
}
}
}
return ret
}

fun removeDocumentFromCache(documentUid: String, uri: Uri): Deferred<Boolean> {
return CoroutineScope(Dispatchers.IO).async {
documentsManager.deleteDocumentFromCache(documentUid, uri)
}
}

/**
* Deletes a Document.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,12 @@ open class DocumentsManager(
* @param documentUid The reference of the document to delete
* @return true if the document was deleted, false otherwise
*/
suspend fun deleteDocumentFromCache(documentUid: String, uri: Uri): Boolean {
suspend fun deleteDocumentFromCache(documentUid: String): Boolean {
val documentUri = documentInCacheOrNull(documentUid)
if (documentUri == null) {
Log.e(tag, "Document not found in cache, deletion aborted!")
return false
}
// if (documentUri != uri) {
// Log.e(tag, "Discrepancy between cache and storage, deletion aborted!")
// return false
// }

val deletedRows = contentResolver.delete(documentUri, null, null)
if (deletedRows > 0) {
Expand All @@ -102,25 +98,7 @@ open class DocumentsManager(
return deletedRows > 0
}

/**
* Delete all documents from the cache for this travel.
* @param travel The reference of the travel to delete the locally stored documents
* @return true if the document was deleted, false otherwise
*/
// suspend fun deleteTravelDocumentsFromCache(travel: TravelContainer): Boolean {
//
//
// val travelDocuments = preferences.filterKeys { it.contains(travel) }
// travelDocuments.forEach { (key, value) ->
// deleteDocumentFromCache(key, Uri.parse(value))
// }
//
// return true
// }

suspend fun downloadAllDocumentsForTravel(travel: TravelContainer) {

}

/**
* Return a Uri pointing to the file in the local storage if it is already present.
Expand Down

0 comments on commit 1a94034

Please sign in to comment.