Add delete encrypted files and fix some crashes

This commit is contained in:
Xpl0itU 2023-07-19 12:39:22 +02:00
parent af70c73bf5
commit 0a1db82aeb
4 changed files with 74 additions and 21 deletions

View file

@ -22,13 +22,13 @@ var (
decryptionError = false
)
func decryptContents(path string, progress *ProgressWindow) error {
func decryptContents(path string, progress *ProgressWindow, deleteEncryptedContents bool) error {
wg.Add(1)
progressInt := 0
go runDecryption(path, &progressInt)
progressInt := 1
go runDecryption(path, &progressInt, deleteEncryptedContents)
progress.percentLabel.SetText("Decrypting...")
for !decryptionDone {
progress.bar.SetFraction(float64(progressInt) / 100)
progress.percentLabel.SetText(fmt.Sprintf("Decrypting... (%d%%)", progressInt))
time.Sleep(500 * time.Millisecond)
}
@ -42,7 +42,7 @@ func decryptContents(path string, progress *ProgressWindow) error {
return nil
}
func runDecryption(path string, progress *int) {
func runDecryption(path string, progress *int, deleteEncryptedContents bool) {
defer wg.Done()
argv := make([]*C.char, 2)
argv[0] = C.CString("WiiUDownloader")
@ -50,5 +50,8 @@ func runDecryption(path string, progress *int) {
if int(C.cdecrypt_main(2, (**C.char)(unsafe.Pointer(&argv[0])), (*C.int)(unsafe.Pointer(progress)))) != 0 {
decryptionError = true
}
if deleteEncryptedContents {
doDeleteEncryptedContents(path)
}
decryptionDone = true
}