Skip to content

Archive.open(file) is freezing in version 2.0.2 #80

@s1067358196

Description

@s1067358196

I faced the same problem as #46 in version 2.0.2.
It works well in version 1.3.0 except that Chinese characters are replaced with '*'.
Is there any solution to decompress package with Chinese characters in filename?
Thank you for any suggestions.

Code

import { Archive } from 'libarchive.js';// 1.3.0
// import { Archive } from 'libarchive.js/dist/libarchive'; // 2.0.2
Archive.init({
  workerUrl: '/dist/worker-bundle.js'
});
console.log('libarchive.js init');

export async function getPackageInfo(file) {
  console.log('file: ', file);
  let obj = null;
  const archive = await Archive.open(file);
  console.log('archive: ', archive);
  obj = await archive.extractFiles();
  console.log('obj: ', obj);
  return obj;
}
<el-upload
      :limit="1"
      class="upload-demo"
      drag
      :before-upload="beforeUpload"
      :auto-upload="false"
      @change="onChange"
      action="/"
      :http-request="httpRequest"
    >
      <el-icon class="el-icon--upload"><upload-filled /></el-icon>
      <div class="el-upload__text">点击或拖拽文件至此上传文件</div>
      <template #tip>
        <div class="el-upload__tip">请上传zip/rar文件</div>
      </template>
    </el-upload>

const onChange: UploadProps['onChange'] = async (file, fileList) => {
  if (canDealPack(file.raw)) {
    previewPackage(file.raw);
  } else {
    window.alert('请上传zip/rar文件');
  }
};
const previewPackage = async (file: File) => {
  try {
    const data = await getPackageInfo(file);
    const record = { children: [] };
    generateMenu(data, record);
    console.log('data: ', data);
    console.log('record: ', record);
    treeData.value = record.children;
    console.log('record: ', record);
  } catch (error) {
    console.log(error);
  }
};

Result

2.0.2
Image
1.0.3 with Chinese dir
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions