Closed GoogleCodeExporter closed 9 years ago
It's pretty common for programs to write new configuration to temp file and
then move the temp file over the original one. That prevents data corruption if
system crashes in the middle of the process or until caches are flushed.
Ideally you should have either original file or the new file, with no
corruption (theory is one thing, reality another, but it at least increases
chances substantially). Some fsync()-like calls are done after the renaming to
ensure the process is complete.
My proposal is - use symlink for the whole config directory, not for a single
config file. I.e.:
$ mv ~/.config/esmska /foo/bar
$ ln -s /foo/bar ~/.config/esmska
should work without problems. Does it solve your need?
Original comment by kamil.paral
on 15 Mar 2011 at 6:31
No, that's not, because I have simlinked just some files from /.config/esmska/.
Well I understand that my problem pretty uncommon, so I'll either just simply
live with it or write patch applied just by me.
Original comment by petr.vo...@gmail.com
on 15 Mar 2011 at 8:58
And what's the reason that you need to have just selected config files
symlinked instead of the whole directory, if I may be so curious? Maybe there
can another solution to your problem, if you explain the main purpose of your
request.
Generally, I'm decided to stick to the principle of renaming files, because
it's much safer for the users. And most of the users won't be able to recover
their config files in the event of file inconsistency after system crash. But I
am willing to do reasonable adjustments not breaking this principle, or provide
an advice to solve your need in some other way.
Original comment by kamil.paral
on 15 Mar 2011 at 9:46
I perfectly understand the reason why you're renaming files. But the current
implementation is:
1) copy old config file to backup
2) delete old config file // File backup = backupFile(destFile);
3) rename new config file to the old one
2) causes my problem :(. Best would be just to skip this and move new config
file directly to the old one (after backup in 1) of course). Looking at Apache
Commons sources tells me that it's not possible to move a file to an existing
file (like mv in unixs does) - it would throw FileExistsException :(.
So I guess I just have to live with this feature :).
PS: I didn't symlinked whole directory, because I need to take some of the
config files from different directories.
Original comment by petr.vo...@gmail.com
on 15 Mar 2011 at 10:56
You still didn't describe what you're trying to achieve. I guess you're trying
to use several different esmska's profiles with shared contacts and other data.
But that's just my guess.
To cut it short: I won't make any changes in saving the files. But you should
be able to satisfy your use case e.g. by making a simple shell wrapper around
esmska command, that will copy appropriate files into ~/.config/esmska before
starting the program and copy them somewhere else after quitting the program.
It depends on your needs.
I'm closing this ticket.
Original comment by kamil.paral
on 16 Mar 2011 at 12:09
Original issue reported on code.google.com by
petr.vo...@gmail.com
on 15 Mar 2011 at 3:51