Merge pull request #2762 from Naveen3Singh/file_size_update_fix

Always request write permission when updating existing file on 30+
This commit is contained in:
Tibor Kaputa 2023-02-01 09:43:46 +01:00 committed by GitHub
commit 729fdc147b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View file

@ -873,11 +873,16 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
ensureBackgroundThread { ensureBackgroundThread {
val file = File(path) val file = File(path)
val fileDirItem = FileDirItem(path, path.getFilenameFromPath()) val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
getFileOutputStream(fileDirItem, true) { try {
if (it != null) { val out = FileOutputStream(file)
saveBitmap(file, bitmap, it, showSavingToast) saveBitmap(file, bitmap, out, showSavingToast)
} else { } catch (e: Exception) {
toast(R.string.image_editing_failed) getFileOutputStream(fileDirItem, true) {
if (it != null) {
saveBitmap(file, bitmap, it, showSavingToast)
} else {
toast(R.string.image_editing_failed)
}
} }
} }
} }

View file

@ -78,10 +78,7 @@ class SaveAsDialog(
if (activity.getDoesFilePathExist(newPath)) { if (activity.getDoesFilePathExist(newPath)) {
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename) val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
ConfirmationDialog(activity, title) { ConfirmationDialog(activity, title) {
val newFile = File(newPath) if ((isRPlus() && !isExternalStorageManager())) {
val isInDownloadDir = activity.isInDownloadDir(newPath)
val isInSubFolderInDownloadDir = activity.isInSubFolderInDownloadDir(newPath)
if ((isRPlus() && !isExternalStorageManager()) && isInDownloadDir && !isInSubFolderInDownloadDir && !newFile.canWrite()) {
val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity)) val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity))
val fileUris = activity.getFileUrisFromFileDirItems(fileDirItem) val fileUris = activity.getFileUrisFromFileDirItems(fileDirItem)
activity.updateSDK30Uris(fileUris) { success -> activity.updateSDK30Uris(fileUris) { success ->