(file)
| 179 | const limit = 2; |
| 180 | |
| 181 | async function processFile(file) { |
| 182 | try { |
| 183 | const entry = zip.files[file]; |
| 184 | |
| 185 | let correctFile = file.replace(/\\/g, "/"); |
| 186 | const isDirEntry = entry.dir || correctFile.endsWith("/"); |
| 187 | |
| 188 | if (isUnsafeAbsolutePath(file)) { |
| 189 | ignoredUnsafeEntries.add(file); |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | correctFile = sanitizeZipPath(correctFile, isDirEntry); |
| 194 | if (!correctFile) return; |
| 195 | |
| 196 | const fileUrl = Url.join(pluginDir, correctFile); |
| 197 | |
| 198 | // Handle directory entries |
| 199 | if (isDirEntry) { |
| 200 | await createFileRecursive(pluginDir, correctFile, true); |
| 201 | return; |
| 202 | } |
| 203 | |
| 204 | // Ensure parent directory exists |
| 205 | const lastSlash = correctFile.lastIndexOf("/"); |
| 206 | if (lastSlash !== -1) { |
| 207 | const parentRel = correctFile.slice(0, lastSlash + 1); |
| 208 | await createFileRecursive(pluginDir, parentRel, true); |
| 209 | } |
| 210 | |
| 211 | if (!state.exists(correctFile)) { |
| 212 | await createFileRecursive(pluginDir, correctFile, false); |
| 213 | } |
| 214 | |
| 215 | let data = await entry.async("ArrayBuffer"); |
| 216 | |
| 217 | if (file === "plugin.json") { |
| 218 | data = JSON.stringify(pluginJson); |
| 219 | } |
| 220 | |
| 221 | if (!(await state.isUpdated(correctFile, data))) return; |
| 222 | |
| 223 | await fsOperation(fileUrl).writeFile(data); |
| 224 | } catch (error) { |
| 225 | console.error(`Error processing file ${file}:`, error); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | // Process in batches |
| 230 | for (let i = 0; i < files.length; i += limit) { |
nothing calls this directly
no test coverage detected