fix: hanlde error in decryption of zip file

This commit is contained in:
SwiftHawk 2024-04-16 13:28:47 +05:00
parent 349e26b628
commit 660efb3b67

View File

@ -5,6 +5,7 @@ import { useState } from 'react'
import { LoadingSpinner } from '../../components/LoadingSpinner'
import { decryptArrayBuffer } from '../../utils'
import styles from './style.module.scss'
import { toast } from 'react-toastify'
export const DecryptZip = () => {
const [selectedFile, setSelectedFile] = useState<File | null>(null)
@ -25,7 +26,14 @@ export const DecryptZip = () => {
const arrayBuffer = await decryptArrayBuffer(
encryptedArrayBuffer,
encryptionKey
)
).catch((err) => {
console.log('err in decryption:>> ', err)
toast.error(err.message || 'An error occurred while decrypting file.')
setIsLoading(false)
return null
})
if (!arrayBuffer) return
const blob = new Blob([arrayBuffer])
saveAs(blob, 'decrypted.zip')