Skip to content

Commit

Permalink
Fix importing projects failing on folders
Browse files Browse the repository at this point in the history
Some zip archives also seem to contain folders so we needed to check for that, instead a file was being created with the name of the folder and then any files contained in that folder would fail causing an error.

Fixes https://discord.com/channels/602097536404160523/1176837626226028544
and
https://discord.com/channels/602097536404160523/1188920392090394736
  • Loading branch information
outercloudstudio committed Dec 25, 2023
1 parent db80f62 commit 3422383
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bridge",
"version": "2.7.7",
"version": "2.7.8",
"private": true,
"scripts": {
"dev": "vite",
Expand Down
6 changes: 5 additions & 1 deletion src/components/FileSystem/Zip/StreamingUnzipper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GenericUnzipper } from './GenericUnzipper'
import { FileSystem } from '../FileSystem'
import { wait } from '/@/utils/wait'
import { invoke } from '@tauri-apps/api/tauri'
import { basename, parse } from '/@/utils/path'

/**
* Streaming variant of the Unzipper class. It is slightly faster and consumes less memory.
Expand Down Expand Up @@ -30,7 +31,10 @@ export class StreamingUnzipper extends GenericUnzipper<Uint8Array> {
const paths = Object.keys(files)
for (let fileIndex = 0; fileIndex < paths.length; fileIndex++) {
const path = paths[fileIndex]
await fs.writeFile(path, new Uint8Array(files[path]))

// Some zip files seem to also contain folders which we need to check for so that we don't create a file
if (path.endsWith(basename(path)))
await fs.writeFile(path, new Uint8Array(files[path]))

this.task?.update(
100 + Math.floor((fileIndex / paths.length) * 100),
Expand Down

0 comments on commit 3422383

Please sign in to comment.