Skip to content

Conversation

@nf
Copy link
Contributor

@nf nf commented Jan 7, 2024

Purpose

Fix #9241 by expanding tildes in version paths.

When creating the versioner file system, first try to expand any leading tildes to the user's home directory before handling relative paths. This makes a version path "~/p" expand to "$HOME/p" instead of "/folder/~/p".

Testing

Added a test to lib/versioner that exercises this code path. Also manually tested with local syncthing instances.

Comment on lines 104 to 105
t.Setenv("USERPROFILE", home)
os.Mkdir(filepath.Join(home, "folder"), 0755)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails on the Windows runner, probably because our legacy HOMEDRIVE/HOMEPATH check takes precedence over USERPROFILE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha, fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not fixed.

\\?\C:\C:\Users\RUNNER~1\AppData\Local\Temp\TestPathTildes1447117282\001\folder\test: The filename, directory name, or volume label syntax is incorrect.

Not sure where the extra C:\ is coming from. Will take another look later today.

Copy link
Member

@calmh calmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and welcome, and thanks for Go and all :)

When creating the versioner file system, first try to expand any leading
tildes to the user's home directory before handling relative paths. This
makes a version path "~/p" expand to "$HOME/p" instead of "/folder/~/p".
@calmh calmh merged commit 8b32138 into syncthing:main Jan 12, 2024
calmh added a commit to calmh/syncthing that referenced this pull request Jan 14, 2024
* main: (24 commits)
  lib/ignore: Refactor out result type (syncthing#9343)
  build: Testing infra images for infra-* branches
  lib/versioner: Expand tildes in version directory (fixes syncthing#9241) (syncthing#9327)
  lib/scanner: Prevent sync-conflict for receive-only local modifications  (syncthing#9323)
  gui, man, authors: Update docs, translations, and contributors
  Fix website security link in README.md (syncthing#9325)
  cmd/syncthing: Add CLI completion functionality (fixes syncthing#8616) (syncthing#9226)
  lib/api: Save session & CSRF tokens to database, add option to stay logged in (fixes syncthing#9151) (syncthing#9284)
  Update dependencies (syncthing#9321)
  gui: Always inform about loading data in Restore Versions modal (syncthing#9317)
  lib/build: Allow semver build in version regex (fixes syncthing#9267) (syncthing#9316)
  gui: Keep short deviceID length consistent + xrefs (fixes syncthing#9313) (syncthing#9314)
  build(deps): bump actions/download-artifact from 3 to 4 (syncthing#9294)
  build(deps): bump actions/upload-artifact from 3 to 4 (syncthing#9293)
  gui, man, authors: Update docs, translations, and contributors
  gui, lib/scanner: Improve scan progress indication (ref syncthing#8331) (syncthing#9308)
  lib/protocol: handle empty names in unixOwnershipEqual (fixes syncthing#9039) (syncthing#9306)
  gui, man, authors: Update docs, translations, and contributors
  etc/linux-desktop: use double dash for long options (syncthing#9301)
  lib/connections: Skip allocation in check for missing port (syncthing#9297)
  ...
@nf
Copy link
Contributor Author

nf commented Jan 14, 2024

Thanks for the fix! ❤️

@calmh calmh added this to the v1.27.3 milestone Jan 22, 2024
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Apr 9, 2025
@syncthing syncthing locked and limited conversation to collaborators Apr 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Versions path does not honor tilde (~) shortcut

3 participants