Skip to content

Commit

Permalink
Fix exporting on firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
tillvit committed Jan 3, 2024
1 parent b006d4e commit 41dc27f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app/src/util/file-handler/WebFileHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ export class WebFileHandler implements BaseFileHandler {
const zipFolder = zip.folder(directoryHandle.name)
if (!zipFolder) {
console.error(
"Failed to zip folder " + path + "/" + directoryHandle.name
"Failed to zip folder " + dirName + "/" + directoryHandle.name
)
continue
}
await this.zipDirectory(path + "/" + directoryHandle.name, zipFolder)
await this.zipDirectory(dirName + "/" + directoryHandle.name, zipFolder)
}
return zip
}
Expand All @@ -344,7 +344,21 @@ export class WebFileHandler implements BaseFileHandler {
})
const zip = await this.zipDirectory(path)
if (!zip) return

await zip.generateAsync({ type: "blob" }).then(async blob => {
if (!window.showSaveFilePicker) {
// showSaveFilePicker bugged on FF
console.log(blob)
const downloadelem = document.createElement("a")
const url = URL.createObjectURL(blob)
document.body.appendChild(downloadelem)
downloadelem.href = url
downloadelem.download = dirName + ".zip"
downloadelem.click()
downloadelem.remove()
window.URL.revokeObjectURL(url)
return
}
await this.writeHandle(fileHandle, blob)
})
}
Expand Down

0 comments on commit 41dc27f

Please sign in to comment.