Voxelum / minecraft-launcher-core-node

Provide packages to install Minecraft, launch Minecraft and more to build launcher with NodeJs/Electron!
https://docs.xmcl.app/en/core/
MIT License
174 stars 25 forks source link

Error tracking download in Install() function #275

Open Gagafeee opened 1 year ago

Gagafeee commented 1 year ago

Hi, I have the folowing code

//...
const task = installTask(await ResolveXmclVersion(version), dir, {});
await task.startAndWait({
  onUpdate(task: any, chunkSize: number) {
    //use only global task called "install"
    if (task.path === 'install') {
      console.log(task.progress + " / " + task.total);

      const downloadPercentage = Math.floor((task.progress * 100) / task.total);
      console.log('Downloading: ' + downloadPercentage + '%');
    }
  },
  onFailed(task: any, error: any) {
    //...
  },
  onSucceed(task: any, result: any) {
    if (task.path === 'install') {
      //...
    }
  }
});

Where I install a minecraft version (tested with 1.20 & 1.19), and track the task named install to have the global downloading. In console: image It seems to have a first download of 34407 bytes, then another (the normal) of 23511027

This problem causes my application's progress bar to go backwards (given that download sends 100% then 0%)

is this from an error indexing the tasks names ? or this is a new file to download before the other ? or this is my mistake ?

Thanks for help