Skip to content

Move index db to $XDG_DATA_HOME/syncthing/ #4924

Closed

Description

@ChristianTacke

Feature Request

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

Activity

  1. calmh commented on May 7, 2018

    @calmh
    Member

    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.

  2. ChristianTacke commented on May 7, 2018

    @ChristianTacke
    Author

    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:

    • If $XDG_DATA_HOME is set, let's use it.
    • if $HOME/.local/share/ exists, use it.
    • Keep the old behaviour. (it's probably not an "XDG Platform")
  3. calmh commented on May 7, 2018

    @calmh
    Member

    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.

  4. ChristianTacke commented on May 7, 2018

    @ChristianTacke
    Author

    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.

  5. ChristianTacke commented on May 7, 2018

    @ChristianTacke
    Author

    Thinking about it, I like your zero'th item: It will calm everybody, who wants to keep stuff in one place.

  6. canton7 commented on May 7, 2018

    @canton7
    Contributor

    Is it worth letting users control the location of the database using a config/env var?

  7. ChristianTacke commented on May 7, 2018

    @ChristianTacke
    Author

    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.
    • What else do we have, that is CON?
  8. calmh commented on May 7, 2018

    @calmh
    Member
  9. Ferroin commented on May 7, 2018

    @Ferroin

    That could also be easily worked around by doing:

    XDG_USER_HOME=h2 syncthing -home h2 -db h2-db
    

    Of course, you could instead just have the -db argument override the auto-detection.

    There's also the question of whether you even want to support a single user running multiple instances.

  10. ChristianTacke commented on May 7, 2018

    @ChristianTacke
    Author

    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.

  11. added
    enhancement
    on Jun 26, 2018
  12. calmh commented on Jun 26, 2018

    @calmh
    Member

    Summarizing, I think we should do something like this;

    1. If the user specified -home, that's where the database goes.
    2. If the database already exists in the config dir (current / old style), that's where it should be.
    3. If $XDG_DATA_HOME is set, that's where the database should be.
    4. Finally, default to the same behavior as now.

    Steps 2-3 are the new ones, adding some auto detection for the database location.

  13. ChristianTacke commented on Jun 26, 2018

    @ChristianTacke
    Author

    With 3. you mean something like the first two bullets in my comment #4924 (comment) ?

  14. calmh commented on Jun 27, 2018

    @calmh
    Member

    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;

    1. If the user specified -home, that's where the database goes.
    2. If the database already exists in the config dir (current / old style), that's where it should be.
    3. If the database already exists in the default XDG data dir (~/.local/share/syncthing), that's where it should be.
    4. If $XDG_DATA_HOME is set, that's where the database should be.
    5. Finally, default to the same behavior as now.
  15. ChristianTacke commented on Jun 27, 2018

    @ChristianTacke
    Author

    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.

  16. 2 remaining items

  17. ChristianTacke commented on Jun 27, 2018

    @ChristianTacke
    Author

    ARG Reopening. I didn't want to close it. Clicked the wrong button.

  18. calmh commented on Jun 27, 2018

    @calmh
    Member

    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?

  19. ChristianTacke commented on Jun 27, 2018

    @ChristianTacke
    Author

    … by the presence of a directory, in my opinion ~/.local/share/. But I am happy with ~/.local/share/syncthing.

  20. desbma commented on Dec 9, 2018

    @desbma
    Contributor

    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.

    Thanks

  21. calmh commented on Dec 10, 2018

    @calmh
    Member

    Until at least #3876 (and possibly other, similar issues) is resolved the index is not an expendable cache.

  22. weilbith commented on Jan 16, 2020

    @weilbith

    Any update on this issue?

  23. calmh commented on Jan 16, 2020

    @calmh
    Member

    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.

  24. added 2 commits that reference this issue on Feb 5, 2020
    2e3b532
    903a6bb
  25. added this to the v1.5.0 milestone on Mar 18, 2020
  26. added
    frozen-due-to-age
    on Mar 19, 2021
  27. locked and limited conversation to collaborators on Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementfrozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions