Skip to content

Commit

Permalink
Use cache dir instead of files dir
Browse files Browse the repository at this point in the history
Installed packages are deleted after installation, but if installation
fails and never retried (for instance: one large package is downloaded
successfully, then a small package is downloaded unsuccessfully due to a
network error, then the user uninstalls the app because it doesn't
work), this can still lead to storage leaks from
downloaded-but-never-installed apps. We should use `cacheDir` instead:
it will allow the system and users to clear the cache themselves.
  • Loading branch information
fynngodau committed Sep 22, 2024
1 parent 3b8509d commit 68ef487
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ internal const val TAG = "GmsPackageInstaller"

const val KEY_BYTES_DOWNLOADED = "bytes_downloaded"

fun Context.packageDownloadLocation() = File(filesDir, FILE_SAVE_PATH).apply {
fun Context.packageDownloadLocation() = File(cacheDir, FILE_SAVE_PATH).apply {
if (!exists()) mkdir()
}

0 comments on commit 68ef487

Please sign in to comment.