fix: handle the case when zip entry is undefined

This commit is contained in:
SwiftHawk 2024-05-16 10:55:44 +05:00 committed by Yury
parent 73b189560f
commit 5356262e34

View File

@ -17,6 +17,11 @@ export const readContentOfZipEntry = async <T extends OutputType>(
// Get the zip entry corresponding to the specified file path // Get the zip entry corresponding to the specified file path
const zipEntry = zip.files[filePath] const zipEntry = zip.files[filePath]
if (!zipEntry) {
toast.error(`Couldn't find file in zip archive at ${filePath}`)
return null
}
// Read the content of the zip entry asynchronously // Read the content of the zip entry asynchronously
const fileContent = await zipEntry.async(outputType).catch((err) => { const fileContent = await zipEntry.async(outputType).catch((err) => {
// Handle any errors that occur during the read operation // Handle any errors that occur during the read operation