feat(cli): send canonical path with each share, list path column - #64
Merged
Conversation
gandermd now upserts shares by (user, path) — re-sharing the same file from the CLI naturally updates the existing share rather than creating a duplicate with a fresh short_id. - canonicalPath() resolves symlinks and cleans the absolute path so the same file shared from different cwd or via symlinks produces one share, not many. - POST /api/shares now carries the canonical path. CLI sends it on every share; the server returns 201 for new, 200 for updated. The CLI uses the server's status plus the local cache to decide whether to print 'Shared ...' or 'Already shared ... — refreshing'. - runShareWithCtx + runWatchAndPushCtx accept a context so tests can stop the watch cleanly. End-to-end watch test rewritten to wait for the PUT (not just any push) before asserting. - list output gains a PATH column; legacy shares without a path render as '-'. - remove <path> canonicalizes the arg before consulting the local map and the server, so symlinks and relative paths match the share the user expects. Pairs with gandermd/gandermd#44. Closes #63.
Collaborator
Author
|
/oc please review this PR and approve if you find it ready to merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
canonicalPath()resolves symlinks and cleans absolute path so the same file shared from different cwd or via symlinks maps to one share.POST /api/sharesnow carries the canonical path. Server returns 201 on insert, 200 on update — CLI uses both the status code and the local cache to choose between "Shared ..." and "Already shared ... — refreshing content in place." messages.listgains a PATH column; legacy shares without a path render as-.remove <path>canonicalizes before consulting the local map or the server, so symlinks and relative paths match.runShareWithCtx+runWatchAndPushCtxtake acontext.Contextso tests can stop the watch cleanly. End-to-end watch test rewritten to wait for the PUT (not just any push) before asserting.Test plan
New tests in
share_test.go:TestCanonicalPathAbsoluteClean— abs + clean outputTestCanonicalPathFollowsSymlink— symlinks resolvedTestCreateShareSendsPathField— POST body contains the pathTestCreateShareReturnsCreatedFlagOnUpdate— server's 200 reflects ascreated=falseTestRunListShowsPathColumn— list output renders the pathTestRunListShowsDashForMissingPath— legacy shares render as-Pairs with gandermd/gandermd#44. Closes #63.
Backward compatibility
The new
pathfield is additive. Old gander builds hit the server withoutpathand dedupe by filename (server-side fallback). New gander builds hit an old gandermd and the unknown field is ignored — same one-share-per-filename behavior as today. The fallback window lets both ship in the same release cycle without a flag day.