#Tauri Updater - Getting download %

26 messages · Page 1 of 1 (latest)

dusky mason
#

Is there a way to get the download % of the update using the onUpdaterEvent? I'm using the server approach for the update (manually calling checkUpdate then installUpdate()

From what I can see at the moment, the only updates we get are "PENDING" and "DOWNLOADED" when using the following code:

const unlisten = await onUpdaterEvent(({ error, status }) => {
  console.log('Updater event', error, status);
});

Note: This is on the JS side, not rust.

I see the rust side has more information about chunk_length etc. Is this not accessible via JS without me forwarding the data to the JS app?

indigo magnet
#

Which version of tauri

dusky mason
#

1.2

crimson yarrow
#

Tauri should emit a tauri://update-download-progress event

#

Either we don't listen to that in onUpdaterEvent or we added it after 1.2

dusky mason
#

so if I do listen('tauri://update-download-progress') and it doesn't work, then it's not implemented in my version? I don't mind updating to the later versions of 1.x if it gets it working but how can I verify this? Searching on github for update-download-progress event didn't show any results 🤔

crimson yarrow
#

apparently it was added 2 years ago that should be 1.0-rc i think

#

looking at the implementation i don't see why this one should work when pending and downloaded do work

dusky mason
#

Thanks for looking.

Just to confirm, it should be accesible via:

onUpdaterEvent(({ error, status }) => {
  console.log('Updater event', error, status);
});

Correct? or should I be listening using the tauri listener import { listen } from '@tauri-apps/api/event'

I.e

const listener = await listen('tauri://update-download-progress', (event) => {
  console.log(event)
})
crimson yarrow
#

listen to it yourself like in your second example

#

i don't hink onUpdaterEvent works correctly but i'll have to check

#

yeah no, it doesn't.

dusky mason
#

Ahhh, excellent. I didn't try the second way so will give it a go. Thanks @crimson yarrow . You always seem to come to our rescue 🤓

pseudo vine
# crimson yarrow listen to it yourself like in your second example

The second example doesn't work with downloadAndInstall (beta.14)

    useEffect(() => {
        console.log("listening to update download progress");
        const unlisten_promise = event.listen("tauri://update-download-progress", (event) => {
            console.log(event);
        });
        return () => {
            console.log("unlistening to update download");
            unlisten_promise.then((unlisten) => unlisten());
        };
    }, []);
crimson yarrow
#

in v2 it's not using events anymore but the hook argument for downloadAndInstall should get the correct progress events now

pseudo vine
crimson yarrow
#

chunkLength is the progress

pseudo vine
crimson yarrow
#

it's the length of the current chunk so you'll have to add them all together to get the total progress

crimson yarrow
#

or it tries to at least

#

seems to be dependend on the Content-Length header send by the server

#

which makes sense i guess

pseudo vine
#

It's pretty confusing but I assume the benefit that it's stateless.

dusky mason
#

I can confirm this event is working in 1.2: