himselfv / wakan

Japanese and Chinese learning tool with dictionary
39 stars 7 forks source link

Some workaround for standalone mode for when the directory is totally not writeable #110

Closed himselfv closed 11 years ago

himselfv commented 11 years ago

Original report by me.

Originally reported on Google Code with ID 110

Currently if there's no wakan.ini file in the same dir Wakan will ask the user to choose
standalone or portable mode, and create one with that settings.

It's okay for portable because if wakan.ini can't be written then surely portable mode
is impossible.

It's also okay for standalone with UAC enabled because Windows will allow Wakan to
put wakan.ini even when running from Program Files.

It's also okay when the app is installed like it should have been, because it installs
in Administrator mode and will ship with pre-configured standalone wakan.ini.

But what if:
1. There's no wakan.ini in the app folder (app was installed from before).
2. UAC is system-wide disabled.

Then we can't put wakan.ini in the same folder and the app will always start into mode
selection.

But wait, this is fine. The only case which gets us here is an upgrade from older Wakan
installation. But firstly, Wakan could not run in this setting before (it was writing
to it's own folder!).

And secondly, upgrade to standalone without writing right to Wakan folder was impossible
in most cases, to begin with. We cannot move files to AppData from Wakan folder unless
it's writeable. So it's even beneficial that we die before copying them, by writing
the upgrade state to wakan.ini, and not after copying and before deleting those. (Which
might result in copying, not moving -- undesirable. I don't know if it will though,
depends on Windows rollback mechanics on move failure)

So it's all good. If you can't make the directory writeable even ONCE when initializing
Wakan for the first time, you have no right to ask the app to run properly. ha ha.

Reported by himselfv on 2013-02-06 14:08:50