After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 639322 - GnuCash should prevent users from storing data files in GNC_DOT_DIR, especial books
GnuCash should prevent users from storing data files in GNC_DOT_DIR, especial...
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Backend - XML
git-master
Other All
: Normal critical
: ---
Assigned To: Geert Janssens
Andreas Köhler
Depends on:
Blocks:
 
 
Reported: 2011-01-12 15:07 UTC by Frank H. Ellenberger
Modified: 2018-06-29 22:51 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Frank H. Ellenberger 2011-01-12 15:07:35 UTC
Again and again new users think "Fine, gnucash made a directory for me, I should use that to keep order." and store their data file in ~/.gnucash/books. Later it is overwritten by the opentab settings for this file and the data are lost.

Suggested procedure: 

1. pop up a warning "It is a bad idea to store data in ...", if the is starting with "~/."

2. Prohibit storing data in "~/.gnucash/books"

This are the path in linux. That on MacOS and windows might differ.
Comment 1 Derek Atkins 2011-01-12 15:09:57 UTC
Another option is to just look for "/.gnucash/" and warn on that, which would work on all platforms.
Comment 2 Frank H. Ellenberger 2011-01-12 16:20:35 UTC
I forgot: It also affects the SQLite backend.
Comment 3 Christian Stimming 2011-01-12 19:59:40 UTC
Huh? I *thought* there was a bugzilla item for exactly this issue before, wasn't it?
Comment 4 Frank H. Ellenberger 2011-01-13 05:57:08 UTC
I couldn't find an open bug. 

Only in some kind related: 
Bug 503722 - Do not store data in Vista's HOME folder, use AppData instead
and related to this again 
Bug 545915 - User Preferences not store in GnuCash / Vista
Comment 5 Christian Stimming 2011-01-13 07:46:30 UTC
Yes, no other bug is open on this. But I thought we had some closed issue on the same topic.
Comment 6 Christian Stimming 2011-01-13 11:57:56 UTC
Ok, I checked myself and no, there is no duplicate.
Comment 7 Frank H. Ellenberger 2011-01-13 12:19:04 UTC
FYI: The most recent thread https://lists.gnucash.org/pipermail/gnucash-user/2011-January/038113.html
Comment 8 Geert Janssens 2011-01-13 13:10:50 UTC
(In reply to comment #1)
> Another option is to just look for "/.gnucash/" and warn on that, which would
> work on all platforms.

I don't think this would work on all platforms. The OS X/Quartz build uses its own path for the gnucash metadata which doesn't match .gnucash. (I deliberatly uses a path without a dot).

But GnuCash as a function to retrieve the actual path uses, namely: gnc_dotgnucash_dir (defined in src/core-utils/gnc-filepath-utils.c:281)

That function could be called to check if a warning should be issued.
Comment 9 Geert Janssens 2011-01-13 14:02:43 UTC
I think a warning is good, but doesn't really touch the core of the issue IMO.

As I also wrote in a reply in the thread referred to in comment 7, the root cause is that the user's data file and the meta data file that GnuCash keeps for it in the books directory can have identical names (which is the case if no spaces are used in the file name).
I think the whole issue could also easily be remedied by changing this: for example by making sure that the metadata file can never have the same name as the user's datafile. The easiest way for that is to add an extension to the metadata files, say .gcm (GnuCash Metadata).

So if your data file is called MyBook.gnucash, the corresponding metadata file would be called MyBook.gnucash.gcm or MyBook.gcm. If the user has more than one MyBook.gnucash, the metadata files could become MyBook.gnucash.1.gcm or Mybook.1.gcm.

The other part of the problem in my opinion is that GnuCash proposes a bad first Save As... location to the user.
I just tried this on Windows XP, with a fully clean install of GnuCash 2.2.9 (though I strongly suspect 2.4.0 behaves the same way). When you create your first book, and then choose Save As..., GnuCash proposes to save the file in
c:\Documents and Settings\<user>\
and not
c:\Documents and Settings\<user>\My Documents
which should be the proper default first location.

A casual user that is not really comfortable with the way the special directories work on Windows will then indeed see .gnucash and inside a books directory. A very tempting location for casual users to store their GnuCash files, resulting in
- users not finding their books again afterwards (c:\Documents and Settings\<user> is not an obvious place for a casual user to look for things.
- users shooting themselves in the foot, because GnuCash overwrites their files in that directory.

So in short, I'd go for a two- or threefold solution:
- add an extension to the metadatafiles to avoid accidental overwrites
- provide a better default save as location (the bugs mentioned in comment 4 may be related to this)
- optionally also warn the user that the "DOT_GNUCASH_DIR" is off-limits for normal data storage.
Comment 10 Geert Janssens 2011-01-13 14:04:54 UTC
By the way, regarding the extension for the metadata files, I think GnuCash should start doing this as soon as possible, yet for backwards compatibility it should also look for and read from a metadatafile without the extension if one with extension is not found. It should however never write again to a metadatafile without extension.
Comment 11 Derek Atkins 2011-01-13 15:17:46 UTC
Geert,

Just for an historical note, the metadata file used to contain the full path to the data file.  That was removed somewhere around 2.0 because people wanted to be able to move their data file without losing state.

I think it's probably reasonable to change the metadata filename, but we should also try to stop people from saving their data files into this location.
Comment 12 John Ralls 2011-01-13 15:34:11 UTC
I agree: Prevent saves in the config directory. It's a simple check in the session save code.

Don't use the explicit string .gnucash, though, use gnc_build_dotgnucash_path(). The directory name can be changed with an environment variable (GNC_DOT_DIR).
Comment 13 Geert Janssens 2011-01-14 22:05:51 UTC
I have committed a series of patches that should deal with this.

These patches implement all three suggestions:
* prevent users from saving/exporting into whatever gnc_dotgnucash_dir() reports
* add extension ".gnc" to the metadata files in the books directory. GC will still look for a metadata file ("state file") without extension if a proper one with extension isn't found, but it will only write to a file with extension.
* first-time Save As... on Windows will now propose the user's "My Documents" as location to save the data file. The previous default location showed the .gnucash directory, which made it very tempting for users to save something in it.
Comment 14 John Ralls 2018-06-29 22:51:46 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=639322. Please update any external references or bookmarks.