Skip to content

Commit

Permalink
sync: better storage access for resources (fixes #3086) (#3315)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Mar 27, 2024
1 parent 4fd90dc commit 29449b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1450
versionName "0.14.50"
versionCode 1451
versionName "0.14.51"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
11 changes: 5 additions & 6 deletions app/src/main/java/org/ole/planet/myplanet/utilities/FileUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,29 @@ object FileUtils {
}

private fun createFilePath(folder: String, filename: String): File {
val directory = File(folder)
val directory = File(MainApplication.context.getExternalFilesDir(null), folder)
if (!directory.exists()) {
try {
if (!directory.mkdirs()) {
throw IOException("Failed to create directory: " + directory.absolutePath)
throw IOException("Failed to create directory: ${directory.absolutePath}")
}
} catch (e: IOException) {
e.printStackTrace()
throw RuntimeException("Failed to create directory: " + directory.absolutePath, e)
throw RuntimeException("Failed to create directory: ${directory.absolutePath}", e)
}
}
Utilities.log("Return file $folder/$filename")
return File(directory, filename)
}

@JvmStatic
fun getSDPathFromUrl(url: String?): File {
return createFilePath(SD_PATH + "/" + getIdFromUrl(url), getFileNameFromUrl(url))
return createFilePath("/ole/" + getIdFromUrl(url), getFileNameFromUrl(url))
}

@JvmStatic
fun checkFileExist(url: String?): Boolean {
if (url.isNullOrEmpty()) return false
val f = createFilePath(SD_PATH + "/" + getIdFromUrl(url), getFileNameFromUrl(url))
val f = getSDPathFromUrl(url)
return f.exists()
}

Expand Down

0 comments on commit 29449b8

Please sign in to comment.