Skip to content

Share folders of your home with other users - #23

Merged
ssenerg merged 1 commit into
mainfrom
home-sharing
Oct 25, 2026
Merged

ssenerg merged 1 commit into
mainfrom
home-sharing

Conversation

@ssenerg

@ssenerg ssenerg commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Stacked on #22 (chunked WebDAV uploads): merge that first, then this one's base becomes main.

What it does

A user can let another user into a folder of their home, or the whole home:

  • People in the folder (a popover next to Share) adds someone by username, who can view what is in it, or edit it too: upload, create folders, rename, overwrite and delete inside, but not delete or rename the shared folder itself.
  • Shared (the top-bar tab, now shown to everyone with a home) lists:
    • Shared with you, first, with Leave;
    • your Shared links, as before;
    • the Folders you share with people, with Stop sharing.
  • Superadmins see and can end every share, but a folder they may not read shows as "Private folder".
  • A user who opens a folder shared with them sees "Shared with you by NAME". The path starts at that folder, and the Shared tab is highlighted.
  • Over WebDAV, /home/ and the owner's home list the way to the shared folder and nothing else of the owner's.
  • Scripts can do the same: action=grant&path=…&user=…&access=read|edit and action=ungrant&id=… on /.shares/ (JSON for scripts, redirects for browsers).

How it works

  • Storage. New table folder_shares (migration 009): owner, real path, user, can_write.
    • Unique per (path, user); sharing again changes the access.
    • At most 200 shares per owner.
    • Rows are deleted (FK cascade) when either user is deleted.
  • Rules. Shares become built-in rules for their user, at the same distance as the home rules, so administrators' rules for the same paths still come first.
    • A shared folder lets its user do only what the owner may still do and share there, just as links work only while their creator may share what they lead to.
    • The user never gets share, so they cannot make links to it or pass it on.
  • Following the folder. Shares follow the folder by real path:
    • rename or move within the home: the share moves with it;
    • deleted (also to the trash), moved out of the home, or replaced by a WebDAV MOVE/COPY with Overwrite: the share ends.
    • When a replace fails, the shares are put back.
    • Leftover shares at a destination path end before another folder moves in.
    • Matching uses the file system's case folding.
  • Quota and trash. What a user adds counts against the owner's home quota. What they delete goes to the trash, where both see it.
  • Cost. RulesFor now does one indexed query per request for the visitor's shares.

Not covered

  • A folder deleted by other means than goftp (directly on disk) keeps its shares until its owner stops them. The README says so.
  • Sharing tells any user with a home whether a username exists. The README notes this too.

Tests

  • internal/auth/people_test.go, on both the memory and Postgres stores:
    • validation;
    • the rules, including the owner's rules and admin rules for the same paths;
    • listing, moves, stale shares, case folding;
    • unsharing by owner, user and superadmin;
    • cascade on user deletion, the limit, and homes moving.
  • internal/server/people_test.go:
    • grant errors;
    • what view and edit allow (the folder itself stays; no links);
    • quota;
    • the Shared page for each side and for a superadmin;
    • rename and move keep the share, delete ends it;
    • leave and stop sharing, with their redirects;
    • WebDAV ways, and replace and failed replace.
  • Full suite passes on Linux (Docker) and with -race + Postgres on macOS (except TestLongNonASCIIPath, which only fails on macOS, as before).
  • I checked the popover, its in-place errors, phone width and both sides of the Shared page in a browser against a local server.

🤖 Generated with Claude Code

A user can now let another user into a folder of their home, or the
whole home, to view what is in it or to edit it too, from a People
popover in the folder. The Shared page lists the folders you share and
those shared with you, where owners stop sharing and users leave.

Shares are built-in rules for their user that allow only what the
owner may do and share there; administrators' rules for the same paths
come first. They follow the folder when it moves within the home, and
end when it is deleted, leaves the home or is replaced, or when either
user is deleted. WebDAV shows the way to them through /home/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ssenerg
ssenerg changed the base branch from chunked-dav to main October 25, 2026 14:43
@ssenerg
ssenerg merged commit 775c989 into main Oct 25, 2026
4 checks passed
@ssenerg
ssenerg deleted the home-sharing branch October 25, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant