Repository: skyline-emu/skyline
File: app/src/main/java/emu/skyline/AppDialog.kt (Kotlin)

Code before:

        if (inputZip == null) {
            Snackbar.make(binding.root, getString(R.string.error), Snackbar.LENGTH_LONG).show()
            return
        }

        val filterTitleId = FilenameFilter { _, dirName -> dirName.matches(Regex("^0100[\\dA-Fa-f]{12}$")) }

        try {
            CoroutineScope(Dispatchers.IO).launch {
                ZipUtils.unzip(inputZip, cacheSaveDir)
                cacheSaveDir.list(filterTitleId)?.forEach { savePath ->
                    File(savesFolder, savePath).deleteRecursively()
                    File(cacheSaveDir, savePath).copyRecursively(File(savesFolder, savePath), true)
                    validZip = true
                }

                withContext(Dispatchers.Main) {
                    if (validZip) {
                        val isSaveFileOfThisGame = File("$savesFolderRoot${item.titleId}").exists()
                        binding.deleteSave.isEnabled = isSaveFileOfThisGame
                        binding.exportSave.isEnabled = isSaveFileOfThisGame
                        Snackbar.make(binding.root, R.string.save_file_imported_ok, Snackbar.LENGTH_LONG).show()
                    } else {
                        Snackbar.make(binding.root, getString(R.string.save_file_invalid_zip_structure), Snackbar.LENGTH_LONG).show()
                    }
                }

                cacheSaveDir.deleteRecursively()
            }
        } catch (e : Exception) {
            Snackbar.make(binding.root, getString(R.string.error), Snackbar.LENGTH_LONG).show()
        }
    }
}


Review comment (suggestion):
```suggestion
                    if (!validZip) {
                        Snackbar.make(binding.root, getString(R.string.save_file_invalid_zip_structure), Snackbar.LENGTH_LONG).show()
                        return@withContext
                    }

                    val isSaveFileOfThisGame = File("$savesFolderRoot${item.titleId}").exists()
                    binding.deleteSave.isEnabled = isSaveFileOfThisGame
                    binding.exportSave.isEnabled = isSaveFileOfThisGame
                    Snackbar.make(binding.root, R.string.save_file_imported_ok, Snackbar.LENGTH_LONG).show()
```

Code after:
        if (inputZip == null) {
            Snackbar.make(binding.root, getString(R.string.error), Snackbar.LENGTH_LONG).show()
            return
        }

        val filterTitleId = FilenameFilter { _, dirName -> dirName.matches(Regex("^0100[\\dA-Fa-f]{12}$")) }

        try {
            CoroutineScope(Dispatchers.IO).launch {
                ZipUtils.unzip(inputZip, cacheSaveDir)
                cacheSaveDir.list(filterTitleId)?.forEach { savePath ->
                    File(savesFolder, savePath).deleteRecursively()
                    File(cacheSaveDir, savePath).copyRecursively(File(savesFolder, savePath), true)
                    validZip = true
                }

                withContext(Dispatchers.Main) {
                    if (!validZip) {
                        Snackbar.make(binding.root, getString(R.string.save_file_invalid_zip_structure), Snackbar.LENGTH_LONG).show()
                        return@withContext
                    }
                    val isSaveFileOfThisGame = File("$savesFolderRoot${item.titleId}").exists()
                    binding.deleteSave.isEnabled = isSaveFileOfThisGame
                    binding.exportSave.isEnabled = isSaveFileOfThisGame
                    Snackbar.make(binding.root, R.string.save_file_imported_ok, Snackbar.LENGTH_LONG).show()
                }

                cacheSaveDir.deleteRecursively()
            }
        } catch (e : Exception) {
            Snackbar.make(binding.root, getString(R.string.error), Snackbar.LENGTH_LONG).show()
        }
    }
}