DownloadWorker: Support downloading OBB and patch files

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-11-06 22:07:17 +05:30
parent 0f4021117f
commit 67bd65be94
2 changed files with 12 additions and 0 deletions

View File

@@ -114,7 +114,11 @@ class DownloadWorker(private val appContext: Context, workerParams: WorkerParame
// Download and verify all files exists
totalBytes = files.sumOf { it.size }
PathUtil.getAppDownloadDir(appContext, app.packageName, app.versionCode).createDirectories()
if (files.any { it.type == GPlayFile.FileType.OBB || it.type == GPlayFile.FileType.PATCH }) {
PathUtil.getObbDownloadDir(app.packageName).createDirectories()
}
val requestList = getDownloadRequest(files)
requestList.forEach { request ->

View File

@@ -89,6 +89,14 @@ object PathUtil {
.toString() + "/Android/obb/" + app.packageName
}
fun getObbDownloadDir(packageName: String): Path {
return Path(
Environment.getExternalStorageDirectory().absolutePath,
"/Android/obb/",
packageName
)
}
fun getObbDownloadFile(app: App, file: File): String {
val obbDir = getObbDownloadPath(app)
return "$obbDir/${file.name}"