DownloadWorker: Support downloading OBB and patch files
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -114,7 +114,11 @@ class DownloadWorker(private val appContext: Context, workerParams: WorkerParame
|
|||||||
|
|
||||||
// Download and verify all files exists
|
// Download and verify all files exists
|
||||||
totalBytes = files.sumOf { it.size }
|
totalBytes = files.sumOf { it.size }
|
||||||
|
|
||||||
PathUtil.getAppDownloadDir(appContext, app.packageName, app.versionCode).createDirectories()
|
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)
|
val requestList = getDownloadRequest(files)
|
||||||
requestList.forEach { request ->
|
requestList.forEach { request ->
|
||||||
|
|||||||
@@ -89,6 +89,14 @@ object PathUtil {
|
|||||||
.toString() + "/Android/obb/" + app.packageName
|
.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 {
|
fun getObbDownloadFile(app: App, file: File): String {
|
||||||
val obbDir = getObbDownloadPath(app)
|
val obbDir = getObbDownloadPath(app)
|
||||||
return "$obbDir/${file.name}"
|
return "$obbDir/${file.name}"
|
||||||
|
|||||||
Reference in New Issue
Block a user