You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
Syncthing already uses $XDG_CONFIG_HOME/syncthing/ for its main configuration.
Could you consider moving the indexdb data to $XDG_DATA_HOME/syncthing/?
This clearly is "data" and the XDG spec says to put "user-specific data files" there.
Why? indexdb can grow large and people can consider to put them on a specific partition for example or exclude them from daily backup and only incude them in weeklys, etc.
Version Information
Syncthing Version: 0.14.37+ds1-1~bpo9+1
OS Version: Debian/stable
Reacted by Tomáš Mládek, desbma, Eric Langlois, Reto, Élia „KopfKrieg“ and Mantas Mikulėnas
We could, and it might even have made sense from the beginning, but at this point I'm not sure it's worth it. It would make Syncthing behave differently on XDG platforms compared to everywhere else, and also open the question for what even is an "XDG platform" to begin with.
I could see something like those three bullet points work. I'd add a zero:th one before, "if the database exists in its current location, continue using that" because suddenly moving potentially gigabytes of data would be unexpected.
Apart from that I like the explicitness of depending on the variable being set or the directory existing. I personally think ~/.local/share is an abomination, but if the user already has it they are presumably fine with it.
That zero'th item sounds fine to me. As you already stated, the alternative would have been to move the indexdb. If both directories are on the same FS, this would be cheap, but we can't know.
Well, .local/share sounds a bit strange, but some tools use .local/lib for architecture specific data. Having seen that, it starts to make sense.
That's the real question here: Should this be done?
@calmh at least seems to be not totally against this.
I am pro it, because it will allow me to better structure my data.
Notes:
This is not inventing a new variable. If implemented, it would use already established variables and specs.
Except for making the code a little more complex (it should be possible to encapsulate all of this in a small, maintainable, reviewable block of code), I can't really see, what would become worse.
A point against this is that today I can easily launch two parallel Syncthing instances:
$ syncthing -home h1 &
$ syncthing -home h2 &
With this change the second instance would crash as despite given separate config locations they share a database location. We'd need an option for the database location as well.
$ syncthing -home h1 -db h1-db &
$ syncthing -home h2 -db h2-db &
I didn't know about the -home option.
Another workaround would be to let -home force zero'th behaviour (db inside config dir).
Yet another is to set $HOME.
I'm not so sure about the second one of those ("if ~/.local/share exists, use that"). There is an intentionality behind setting the environment variable. The path, however, might have been created by some other program that just always assumes XDG paths, incorrectly - like, some Java stuff on my Mac, which should use ~/Library/Application Support like everything else.
That said, if there is a Syncthing database in ~/.local/share/syncthing we should definitely use that. So there is an additional point 2.5 for checking that;
If the user specified -home, that's where the database goes.
If the database already exists in the config dir (current / old style), that's where it should be.
If the database already exists in the default XDG data dir (~/.local/share/syncthing), that's where it should be.
If $XDG_DATA_HOME is set, that's where the database should be.
The idea behind the original "check for ~/.local/share" was to check for an "XDG Platform". I didn't know about those broken programs. We could in theory say "We should not jump through hoops, because others create broken programs".
That said, I think, the check for ${XDG_DATA_HOME=~/.local/share}/syncthing is fine. It's "The user wants XDG for syncthing".
But please exchange point 3 and 4: IF $XDG_DATA_HOME is set, we have no reason to even start looking at ~/.local/share, let alone …/syncthing.
The problem, as I see it, is that the whole XDG thing only applies to a subset of the systems in the world and it's not clear to me how to determine if any given system is one of those. If not by the presence of the env var, then how?
I would like to submit using ~/.cache/syncthing (XDG_CACHE_HOME) instead of (~/.local/share/syncthing (XDG_DATA_HOME)
In my opinion the descriptions leaves no doubt for the database case:
$XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
vs
$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored.
I consider the database "non essential" because if it is missing it will be rebuilt on the next Syncthing startup.
And of course, most people exclude ~/.cache from backups and not ~/.local/share.
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
Activity
calmh commentedon May 7, 2018
We could, and it might even have made sense from the beginning, but at this point I'm not sure it's worth it. It would make Syncthing behave differently on XDG platforms compared to everywhere else, and also open the question for what even is an "XDG platform" to begin with.
ChristianTacke commentedon May 7, 2018
Well, glib has an answer to the "XDG Platform" question for the data dir: https://developer.gnome.org/glib/stable/glib-Miscellaneous-Utility-Functions.html#g-get-user-data-dir
Maybe go has something alike?
You could even do something like this:
$XDG_DATA_HOMEis set, let's use it.$HOME/.local/share/exists, use it.calmh commentedon May 7, 2018
I could see something like those three bullet points work. I'd add a zero:th one before, "if the database exists in its current location, continue using that" because suddenly moving potentially gigabytes of data would be unexpected.
Apart from that I like the explicitness of depending on the variable being set or the directory existing. I personally think
~/.local/shareis an abomination, but if the user already has it they are presumably fine with it.ChristianTacke commentedon May 7, 2018
That zero'th item sounds fine to me. As you already stated, the alternative would have been to move the indexdb. If both directories are on the same FS, this would be cheap, but we can't know.
Well,
.local/sharesounds a bit strange, but some tools use.local/libfor architecture specific data. Having seen that, it starts to make sense.ChristianTacke commentedon May 7, 2018
Thinking about it, I like your zero'th item: It will calm everybody, who wants to keep stuff in one place.
canton7 commentedon May 7, 2018
Is it worth letting users control the location of the database using a config/env var?
ChristianTacke commentedon May 7, 2018
That's the real question here: Should this be done?
Notes:
calmh commentedon May 7, 2018
Ferroin commentedon May 7, 2018
That could also be easily worked around by doing:
Of course, you could instead just have the
-dbargument override the auto-detection.There's also the question of whether you even want to support a single user running multiple instances.
ChristianTacke commentedon May 7, 2018
I didn't know about the
-homeoption.Another workaround would be to let
-homeforce zero'th behaviour (db inside config dir).Yet another is to set
$HOME.calmh commentedon Jun 26, 2018
Summarizing, I think we should do something like this;
-home, that's where the database goes.$XDG_DATA_HOMEis set, that's where the database should be.Steps 2-3 are the new ones, adding some auto detection for the database location.
ChristianTacke commentedon Jun 26, 2018
With 3. you mean something like the first two bullets in my comment #4924 (comment) ?
calmh commentedon Jun 27, 2018
I'm not so sure about the second one of those ("if ~/.local/share exists, use that"). There is an intentionality behind setting the environment variable. The path, however, might have been created by some other program that just always assumes XDG paths, incorrectly - like, some Java stuff on my Mac, which should use ~/Library/Application Support like everything else.
That said, if there is a Syncthing database in ~/.local/share/syncthing we should definitely use that. So there is an additional point 2.5 for checking that;
-home, that's where the database goes.~/.local/share/syncthing), that's where it should be.$XDG_DATA_HOMEis set, that's where the database should be.ChristianTacke commentedon Jun 27, 2018
The idea behind the original "check for
~/.local/share" was to check for an "XDG Platform". I didn't know about those broken programs. We could in theory say "We should not jump through hoops, because others create broken programs".That said, I think, the check for
${XDG_DATA_HOME=~/.local/share}/syncthingis fine. It's "The user wants XDG for syncthing".But please exchange point 3 and 4: IF
$XDG_DATA_HOMEis set, we have no reason to even start looking at~/.local/share, let alone…/syncthing.2 remaining items
ChristianTacke commentedon Jun 27, 2018
ARG Reopening. I didn't want to close it. Clicked the wrong button.
calmh commentedon Jun 27, 2018
The problem, as I see it, is that the whole XDG thing only applies to a subset of the systems in the world and it's not clear to me how to determine if any given system is one of those. If not by the presence of the env var, then how?
ChristianTacke commentedon Jun 27, 2018
… by the presence of a directory, in my opinion
~/.local/share/. But I am happy with~/.local/share/syncthing.desbma commentedon Dec 9, 2018
I would like to submit using
~/.cache/syncthing(XDG_CACHE_HOME) instead of (~/.local/share/syncthing(XDG_DATA_HOME)In my opinion the descriptions leaves no doubt for the database case:
vs
I consider the database "non essential" because if it is missing it will be rebuilt on the next Syncthing startup.
And of course, most people exclude
~/.cachefrom backups and not~/.local/share.Thanks
calmh commentedon Dec 10, 2018
Until at least #3876 (and possibly other, similar issues) is resolved the index is not an expendable cache.
weilbith commentedon Jan 16, 2020
Any update on this issue?
calmh commentedon Jan 16, 2020
I sure don't see any.
Like many other issues, this one requires someone who actually cares about it to step up and put in some elbow grease.
cmd/syncthing, lib/locations: Separate data and config dirs (fixes sy…
cmd/syncthing, lib/locations: Separate data and config dirs (fixes sy…