jdarwood007 commited on 2023-04-13 15:52:42
Showing 1 changed files, with 18 additions and 0 deletions.
... | ... |
@@ -192,6 +192,8 @@ async function processFile() |
192 | 192 |
/* This function retrieves a file from the archive for use later */ |
193 | 193 |
async function fetchFileFromArchive(fileName) |
194 | 194 |
{ |
195 |
+ let fileData = null; |
|
196 |
+ |
|
195 | 197 |
if (usingArchive == 'zip') |
196 | 198 |
{ |
197 | 199 |
// The zip handler treats them as objects, but we need to ensure we can find files regardless of case, so we find the match, to find the real file name. |
... | ... |
@@ -217,7 +219,23 @@ async function fetchFileFromArchive(fileName) |
217 | 219 |
throw new Error('Unable to find ' + fileName); |
218 | 220 |
|
219 | 221 |
// Get our file data from the index we have. |
222 |
+ let UseBlob = false; |
|
223 |
+ try { |
|
220 | 224 |
fileData = await archiveData[index].readAsString(); |
225 |
+ } |
|
226 |
+ catch (err) { |
|
227 |
+ if (err.message.indexOf('Maximum call stack size exceeded') > -1) |
|
228 |
+ UseBlob = true; |
|
229 |
+ else |
|
230 |
+ throw err; |
|
231 |
+ } |
|
232 |
+ |
|
233 |
+ // Sometimes we need to use blob because to get around maximum call stack size exceeded |
|
234 |
+ if (UseBlob == true && fileData == null) |
|
235 |
+ { |
|
236 |
+ const fileBlob = await archiveData[index].blob; |
|
237 |
+ fileData = await new Response(fileBlob).text(); |
|
238 |
+ } |
|
221 | 239 |
|
222 | 240 |
return fileData; |
223 | 241 |
} |
224 | 242 |