Skip to content

Commit 44044aa

Browse files
committed
feat: migrate downloads to public "Downloads/GitHub Store" directory
- Update `AndroidFileLocationsProvider` to use the public `DIRECTORY_DOWNLOADS` directory instead of app-private external storage. - Modify `userDownloadsDir()` to return the same public path as `appDownloadsDir()`. - Update `filepaths.xml` to include the new public path under `Download/GitHub Store/` for FileProvider access. - Rename the existing private path to `ghs_legacy_downloads` in `filepaths.xml` to support migration from older versions. - Ensure the "GitHub Store" subdirectory is created automatically within the public Downloads folder.
1 parent 95f2125 commit 44044aa

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

composeApp/src/androidMain/res/xml/filepaths.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<paths xmlns:android="http://schemas.android.com/apk/res/android">
33

4-
<external-files-path
4+
<!-- Public Downloads/GitHub Store folder (visible in file managers) -->
5+
<external-path
56
name="ghs_downloads"
7+
path="Download/GitHub Store/" />
8+
9+
<!-- Legacy app-private downloads (for migration) -->
10+
<external-files-path
11+
name="ghs_legacy_downloads"
612
path="/" />
713

814
<cache-path

core/data/src/androidMain/kotlin/zed/rainxch/core/data/services/AndroidFileLocationsProvider.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
package zed.rainxch.core.data.services
22

33
import android.content.Context
4+
import android.os.Environment
45
import java.io.File
56

67
class AndroidFileLocationsProvider(
78
private val context: Context,
89
) : zed.rainxch.core.data.services.FileLocationsProvider {
910
override fun appDownloadsDir(): String {
10-
val externalFilesRoot = context.getExternalFilesDir(null)
11-
val dir = File(externalFilesRoot, "ghs_downloads")
11+
val publicDownloads = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
12+
val dir = File(publicDownloads, "GitHub Store")
1213
if (!dir.exists()) dir.mkdirs()
1314
return dir.absolutePath
1415
}
1516

1617
override fun userDownloadsDir(): String {
17-
return "" // No-op
18+
return appDownloadsDir()
1819
}
1920

2021
override fun setExecutableIfNeeded(path: String) {

0 commit comments

Comments
 (0)