nika-begiashvili / libarchivejs

Archive library for browsers
MIT License
288 stars 35 forks source link

ISO file creation returns an archive size of 0, while gzip creation works fine #71

Open suntranscend opened 5 months ago

suntranscend commented 5 months ago

When attempting to create an ISO file using libarchive.js, the returned archive size is 0 bytes. However, when creating a gzip file with the same process and files, the output is correct and functional. Below is the code snippet used for creating the ISO file:


import {
  Archive,
  ArchiveFormat,
  ArchiveCompression,
} from 'libarchive.js/dist/libarchive.js';

// `files` is the files of the input of the file type.
const allFiles = [];
for (let i = 0; i < files.length; i++) {
  const file = files[i];
  const relativePath =
    file.webkitRelativePath || file.relativePath || file.name;
  allFiles.push({ file, pathname: relativePath });
}

const archiveFile = await Archive.write({
  files: allFiles,
  outputFileName: 'mount.iso',
  compression: ArchiveCompression.NONE,
  format: ArchiveFormat.ISO9660,
  passphrase: null,
});

Steps to Reproduce:

Prepare a list of files to be included in the archive (allFiles). Use the above code snippet to attempt to create an ISO file. Check the size of the generated mount.iso file.

Expected Behavior:

The ISO file should be created with the appropriate size, containing all the specified files.

Actual Behavior:

The generated ISO file (mount.iso) has a size of 0 bytes.

Additional Information:

Environment: