viper icon indicating copy to clipboard operation
viper copied to clipboard

feat: handle unzip errors

Open Jan200101 opened this issue 1 year ago • 14 comments

fixes #238 fixes #240

handles unzip failures gracefully with visual feedback in the UI

image

Jan200101 avatar Aug 04 '24 21:08 Jan200101

As it stands, I'm not sure I'd agree that this fixes those issues, but were you to add something like "this may happens due to file permissions" or similar, it'd be a different story. But even so, those issues should be caught much earlier than the unzipping process imo

0neGal avatar Aug 04 '24 22:08 0neGal

sure, but this should be done regardless. this is just a blanket solution that gracefully deals with all errors during unzipping, actually checking if we have the permission to put files in place could be done ahead of time though we should look to avoid what FlightCore does and not check for a hardcoded path

Jan200101 avatar Aug 04 '24 22:08 Jan200101

sure, but this should be done regardless. this is just a blanket solution that gracefully deals with all errors during unzipping

Totally agree

actually checking if we have the permission to put files in place could be done ahead of time though we should look to avoid what FlightCore does and not check for a hardcoded path

Also agree, however keep in mind, there was already some attempt to make this be a thing, and it did work in my testing on Linux, as mentioned in those issues, I've however not been able to get around to if it's just on Windows it breaks, and why...

0neGal avatar Aug 04 '24 22:08 0neGal

Also agree, however keep in mind, there was already some attempt to make this be a thing, and it did work in my testing on Linux, as mentioned in those issues, I've however not been able to get around to if it's just on Windows it breaks, and why...

Oh yeah thats kinda expected. fs.accessSync doesn't really work with directories on windows, libuv does some minor checks and then pretends everything is a-okay since access isn't controlled by metadata but by a lot more complicated stuff that cannot be sanely put into the RWX format.

what could be added after the accessSync is an attempt to create a file and delete it.

Jan200101 avatar Aug 04 '24 22:08 Jan200101

I figured Windows did some dumb stuff underneath or handled something different oh well, any fix is appreciated really... Whether it's recursively checking the files inside, or creating a file etc

0neGal avatar Aug 04 '24 22:08 0neGal

permission check for Windows was added. I didn't make it check specifically for windows since this is such a minor thing. image

Jan200101 avatar Aug 05 '24 17:08 Jan200101

the last thing I want to propose here is making gamepath-lost-perms create a toast message that would call setpath on click.

Currently it creates an alert box and opens the setpath dialog on loop until you select a path with permissions or until the user terminates the app because gamepath.setting keeps being set to false when the file dialog is closed.

Jan200101 avatar Aug 05 '24 17:08 Jan200101

The original intention was that the dialog would show, and it'd disable the buttons beside the gamepath related ones, letting you mount the drive or fix permissions etc without having to set the gamepath again. Just to clarify, are you saying the permission alert continuously show keeps popping up? Because that would be unintentional

0neGal avatar Aug 05 '24 18:08 0neGal

Just to clarify, are you saying the permission alert continuously show keeps popping up? Because that would be unintentional

yes, that is what is happening.

The loop goes like this: setInterval(gamepath.js:L193) emits gamepath-lost-perms gamepath-lost-perms emits setpath if gamepath.setting is false and sets it to true setpath calls gamepath.set gamepath.set opens the file dialog via dialog.showOpenDialog and sets gamepath.setting to false in its callback handler. because gamepath.setting is false gamepath-lost-perms can start the dialog again.

Jan200101 avatar Aug 05 '24 18:08 Jan200101

I see, I suppose you could do:

ipcMain.on("gamepath-lost-perms", async (e, selected_gamepath) => {
	if (! gamepath.setting && ! gamepath.lost_perms == selected_gamepath) {
		gamepath.lost_perms = selected_gamepath;

		// remaining code ...
	}
})

And then clear gamepath.lost_perms whenever a gamepath is set or the permissions have been restored.

0neGal avatar Aug 05 '24 18:08 0neGal

Anything still needed for this to be merged?

  • general unzip failures are handles and propagated up with the ability to print specific messages for certain failures
    • a message for permission denied was added, though it may be best to omit that for now since the existing permission check should handle this. a follow-up PR could add it and other checks in.
  • permissions check was updated to check for permissions and try a filesystem operation for maximum coverage
  • toast over IPC was fixed
  • race condition for permission check was fixed

Jan200101 avatar Aug 10 '24 08:08 Jan200101

Besides localization, this should be able to be merged.

0neGal avatar Aug 10 '24 15:08 0neGal

reverted unneeded localization changes, added german translation. Poked Alystrasz on Discord for a French translation, would need to ask @XNovaDelta for the spanish one. I don't know if KenMizz is still away, so I'll try finding someone for the chinese translation again. EDIT: found one

Jan200101 avatar Aug 10 '24 18:08 Jan200101

was asked to ping here so they are aware when they are back @Alystrasz

Jan200101 avatar Aug 10 '24 20:08 Jan200101

Just as a refresher, was the only thing missing in this PR the Spanish localizations? If so, I intend to make an issue dedicated to fixing that later on, and just merging this directly...

0neGal avatar Dec 20 '24 00:12 0neGal

as far as I am aware, only the spanish localization is missing.

Jan200101 avatar Dec 20 '24 07:12 Jan200101