diff options
author | Charles Lombardo <clombardo169@gmail.com> | 2023-10-13 19:50:38 +0200 |
---|---|---|
committer | Charles Lombardo <clombardo169@gmail.com> | 2023-10-13 19:50:38 +0200 |
commit | 82c845dc2fef9ab29baa9fb0c08131a16384cd0f (patch) | |
tree | d9472976c091428048b3da2fe93a885194caa9f7 /src/android/app | |
parent | Improvement in Directory Path Detection for Shortcuts (#11749) (diff) | |
download | yuzu-82c845dc2fef9ab29baa9fb0c08131a16384cd0f.tar yuzu-82c845dc2fef9ab29baa9fb0c08131a16384cd0f.tar.gz yuzu-82c845dc2fef9ab29baa9fb0c08131a16384cd0f.tar.bz2 yuzu-82c845dc2fef9ab29baa9fb0c08131a16384cd0f.tar.lz yuzu-82c845dc2fef9ab29baa9fb0c08131a16384cd0f.tar.xz yuzu-82c845dc2fef9ab29baa9fb0c08131a16384cd0f.tar.zst yuzu-82c845dc2fef9ab29baa9fb0c08131a16384cd0f.zip |
Diffstat (limited to 'src/android/app')
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt index 10b1d3547..df21d74b2 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt @@ -26,6 +26,7 @@ import org.yuzu.yuzu_emu.model.DriverViewModel import org.yuzu.yuzu_emu.model.HomeViewModel import org.yuzu.yuzu_emu.utils.FileUtil import org.yuzu.yuzu_emu.utils.GpuDriverHelper +import java.io.File import java.io.IOException class DriverManagerFragment : Fragment() { @@ -154,29 +155,29 @@ class DriverManagerFragment : Fragment() { R.string.installing_driver, false ) { + val driverPath = + "${GpuDriverHelper.driverStoragePath}/${FileUtil.getFilename(result)}" + val driverFile = File(driverPath) + // Ignore file exceptions when a user selects an invalid zip try { - GpuDriverHelper.copyDriverToInternalStorage(result) + if (!GpuDriverHelper.copyDriverToInternalStorage(result)) { + throw IOException("Driver failed validation!") + } } catch (_: IOException) { + if (driverFile.exists()) { + driverFile.delete() + } return@newInstance getString(R.string.select_gpu_driver_error) } - val driverData = GpuDriverHelper.customDriverData - if (driverData.name == null) { - return@newInstance getString(R.string.select_gpu_driver_error) - } - + val driverData = GpuDriverHelper.getMetadataFromZip(driverFile) val driverInList = driverViewModel.driverList.value.firstOrNull { it.second == driverData } if (driverInList != null) { return@newInstance getString(R.string.driver_already_installed) } else { - driverViewModel.addDriver( - Pair( - "${GpuDriverHelper.driverStoragePath}/${FileUtil.getFilename(result)}", - driverData - ) - ) + driverViewModel.addDriver(Pair(driverPath, driverData)) driverViewModel.setNewDriverInstalled(true) } return@newInstance Any() |