capawesome-team / capacitor-plugins

⚡️ Community plugins for Capacitor. Supports Android, iOS and the Web.
https://capawesome.io/plugins/
169 stars 25 forks source link

bug: Zip plugin doesn't work properly #176

Closed loremru closed 3 days ago

loremru commented 1 week ago

Plugin(s)

Version

6.0.0

Platform(s)

Current behavior

not full unpacking, just part of archieve and there is no error

Expected behavior

upack all zip

Reproduction

code below

Steps to reproduce


import { Directory, Filesystem } from '@capacitor/filesystem'
import { Zip } from '@capawesome-team/capacitor-zip'

export async function downloadRegion() {
  const r = await Filesystem.downloadFile({
    url: 'https://storage.yandexcloud.net/gunza-maps/satellite/85.zip',
    directory: Directory.Library,
    path: '/satellite.zip',
    progress: true,
  })

  try {
    await Filesystem.requestPermissions()
    console.log((await Filesystem.stat({ directory: Directory.Library, path: 'satellite.zip' })).size)
    await Zip.unzip({
      source: r.path as string,
      destination: (await Filesystem.getUri({ path: 'satellite', directory: Directory.Library })).uri,
    })
    console.log('FILES0', await Filesystem.readdir({ directory: Directory.Library, path: 'satellite' }))
    console.log((await Filesystem.stat({ directory: Directory.Library, path: 'satellite' })).size)
  } catch (e) {
    console.log('ERR: ', e)
  }
}

Other information

image

24576 bytes of 10515726 bytes

85.zip

Capacitor doctor

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 6.0.0 @capacitor/core: 6.0.0 @capacitor/android: 6.0.0 @capacitor/ios: 6.0.0

Installed Dependencies:

@capacitor/cli: 6.0.0 @capacitor/core: 6.0.0 @capacitor/android: 6.0.0 @capacitor/ios: 6.0.0

[success] iOS looking great! 👌 [success] Android looking great! 👌

Before submitting

robingenz commented 1 week ago

Thank you for your request. The plugin is quite new and not yet heavily tested. I will take a look tomorrow and get back to you. Please attach the zip file to this GitHub issue.

loremru commented 1 week ago

@robingenz

You can get it from https://storage.yandexcloud.net/gunza-maps/satellite/85.zip

or download it direct to device through FIlesystem.downloadFile like I did

robingenz commented 1 week ago

I've just tested it and it worked without issues. I've used the following code for testing:

  public async unzip(): Promise<void> {
    // Download the file
    const { path } = await Filesystem.downloadFile({
      url: 'https://storage.yandexcloud.net/gunza-maps/satellite/85.zip',
      directory: Directory.Library,
      path: 'satellite.zip',
    });
    if (!path) {
      return;
    }
    // Create the destination directory
    const directoryName = `${Date.now().toString()}`;
    await Filesystem.mkdir({
      path: directoryName,
      directory: Directory.Library,
      recursive: true,
    });
    const { uri: destinationUri } = await Filesystem.getUri({
      path: directoryName,
      directory: Directory.Library,
    });
    // Unzip the file
    await Zip.unzip({
      source: path,
      destination: destinationUri,
    });
    // List the files in the destination directory
    await Filesystem.readdir({
      path: destinationUri,
    });
  }

grafik