forked from chinosk/gkms-local
				
			delete cache
This commit is contained in:
		
							parent
							
								
									8ddd6f53bc
								
							
						
					
					
						commit
						f82e73845a
					
				| 
						 | 
					@ -565,22 +565,26 @@ class PatchActivity : ComponentActivity() {
 | 
				
			||||||
            return Array(size, nonceItem).joinToString("")
 | 
					            return Array(size, nonceItem).joinToString("")
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        fun saveFilesToDownload(context: PatchActivity, apkFiles: List<File>, targetFolder: String): List<String>? {
 | 
					        fun saveFilesToDownload(context: PatchActivity, apkFiles: List<File>, targetFolder: String,
 | 
				
			||||||
 | 
					                                isMove: Boolean): List<String>? {
 | 
				
			||||||
            val ret: MutableList<String> = mutableListOf()
 | 
					            val ret: MutableList<String> = mutableListOf()
 | 
				
			||||||
            apkFiles.forEach { f ->
 | 
					            apkFiles.forEach { f ->
 | 
				
			||||||
                val success = context.writeFileToDownloadFolder(f, "gkms_local_patch", f.name)
 | 
					                val success = context.writeFileToDownloadFolder(f, targetFolder, f.name)
 | 
				
			||||||
                if (success) {
 | 
					                if (success) {
 | 
				
			||||||
                    ret.add(f.name)
 | 
					                    ret.add(f.name)
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else {
 | 
					                else {
 | 
				
			||||||
                    val newName = "${generateNonce(6)}${f.name}"
 | 
					                    val newName = "${generateNonce(6)}${f.name}"
 | 
				
			||||||
                    val success2 = context.writeFileToDownloadFolder(f, "gkms_local_patch",
 | 
					                    val success2 = context.writeFileToDownloadFolder(f, targetFolder,
 | 
				
			||||||
                        newName)
 | 
					                        newName)
 | 
				
			||||||
                    if (!success2) {
 | 
					                    if (!success2) {
 | 
				
			||||||
                        return null
 | 
					                        return null
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    ret.add(newName)
 | 
					                    ret.add(newName)
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                if (isMove) {
 | 
				
			||||||
 | 
					                    f.delete()
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return ret
 | 
					            return ret
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -597,7 +601,7 @@ class PatchActivity : ComponentActivity() {
 | 
				
			||||||
                    val targetDirectory = File(sdcardPath, "Download/gkms_local_patch")
 | 
					                    val targetDirectory = File(sdcardPath, "Download/gkms_local_patch")
 | 
				
			||||||
                    // val savedFiles = saveFileTo(apkFiles, targetDirectory, true, false)
 | 
					                    // val savedFiles = saveFileTo(apkFiles, targetDirectory, true, false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    val savedFileNames = saveFilesToDownload(context, apkFiles, "gkms_local_patch")
 | 
					                    val savedFileNames = saveFilesToDownload(context, apkFiles, "gkms_local_patch", true)
 | 
				
			||||||
                    if (savedFileNames == null) {
 | 
					                    if (savedFileNames == null) {
 | 
				
			||||||
                        status = PackageInstaller.STATUS_FAILURE
 | 
					                        status = PackageInstaller.STATUS_FAILURE
 | 
				
			||||||
                        message = "Save files failed."
 | 
					                        message = "Save files failed."
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue