Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

12.2 KB
Raw Blame

Shares

The shares module exposes existing storage through share aliases. A share does not copy its source and does not become the owner of the underlying storage.

Access and permission model

Receiving and managing shares are separate application capabilities. SHARES allows a user or guest to browse shares/<share-alias>/..., while SHARES_ADMIN allows an authorized user account to create, update, disable, and delete shares and their links. Effective membership can be granted directly, through a group, or through a link pseudo-user.

Members can read an enabled share. Additional operations reuse the space permission model, except that SHARE_INSIDE does not apply:

Operation Backend permission Meaning
Add ADD Create, upload, copy, or move content into a directory
Modify MODIFY Edit content and manage locks
Delete DELETE Delete content or move it out of its current location
Share SHARE_OUTSIDE Create a child share or a link from the exposed content

A move requires DELETE on the source and ADD on the destination. Permissions granted to members, groups, guests, links, and child shares are intersected with the creator's effective permissions on the source. Personal content starts with the owner's full file permissions; content reached through a collaborative space or parent share remains capped by that context.

The source provenance is required internally for authorization, quota, path, and deletion routing, but recipient-facing views must not expose whether the source came from personal files or a collaborative space. Owner and administration views may expose the source context for management purposes.

Share identity and lifecycle

A common share is addressed by its globally unique alias; name is the display name shown to recipients and may differ from the source name. Description and enabled state also belong to the share definition. Disabling a share preserves its source, memberships, descendants, and settings but makes the endpoint unavailable until it is enabled again.

File-backed shares retain source identity through shares.fileId, while gateway shares use spaceRootId or externalPath. Renaming or moving a file-backed source within the same logical repository updates the existing file record, so the share remains attached without copying data. Permanently deleting the source removes dependent share definitions through their database relations.

The share owner can manage the share and its descendant hierarchy. Managers of an originating collaborative space can also administer shares created from that space. Deleting or disabling a share definition is distinct from deleting content while browsing the share; those behaviors are detailed below.

External locations

An administrator can expose an existing server directory as a root external share. The share stores the directory in shares.externalPath, has no backing fileId, and sets ownerId to null because no managed user or native space owns that storage. No content is copied, and the share alias is only the virtual entry point into the external directory.

External-share creation verifies that the path exists and that the operating-system account running the server can read and write it. These shares are visible and manageable by administrators. Their canonical root owns the share-level quota and indexing configuration; nested shares preserve the external provenance but reuse the highest ancestor's storage scope.

Because an external share has no managed storage owner, the current backend does not route deletions to the actor's personal trash. Content deleted through the share is removed permanently according to the policy described below.

Storage provenance

The share keeps enough provenance to resolve the physical source and its managed storage owner:

Share source Storage provenance
Personal files The source file's ownerId
Native space The source spaceId
External root attached to a native space The source spaceId and spaceRootId
External share The root share's externalPath and files.shareExternalId
Child of an external share The highest external parent and a path below its externalPath

For a native-space external root, the native space remains the managed storage owner even though the files are physically outside its home.

A root external share has no managed user or native-space storage owner. Its ownerId is therefore null. A child share can have an ownerId identifying the owner of the share record, but that value is not storage ownership and must not be used to select a user trash repository.

Files indexed below an external share use files.shareExternalId. For a child share, this identifier refers to the highest external parent so that every descendant resolves against the same physical external root.

Nested-share hierarchy and external storage scope

Nested external shares have two independent ancestry concepts:

  • shares.parentId always identifies the immediate parent. It defines the share hierarchy and drives permission delegation and propagation.
  • files.shareExternalId identifies the highest external ancestor. For descendants, SpaceEnv.root.externalParentShareId carries that canonical storage scope to file operations.

For a hierarchy A -> B -> C, where A is the root external share:

Share Immediate parentId Canonical files.shareExternalId
A null A
B A A
C B A

Resolving the external storage scope must never rewrite shares.parentId. File metadata, lock conflict checks and cleanup, and event and quota repository routing must all use the same canonical files.shareExternalId. A correct physical path is not sufficient to identify this logical scope.

If the highest external ancestor cannot be resolved, the operation must fail before modifying the filesystem. It must not fall back to the immediate parent, the current descendant, or the authenticated actor.

Quota routing

Quota enforcement follows the storage provenance rather than the actor or the share currently being browsed:

Shared storage Applied quota
Personal files Source owner's personal quota
Native-space files Origin space quota
External root attached to a native space Origin space quota
Root external share and its descendants Highest external ancestor share quota

Share-level storageUsage, storageQuota, and storageIndexing are meaningful only for the canonical external root. Descendant share rows may retain the external path for resolution, but operations reuse the highest external ancestor and must not establish independent quota ownership.

Child-share permission delegation

Creating a child share requires the effective SHARE_OUTSIDE permission on its immediate parent. Requested member and link permissions are intersected with the creator's effective permissions on that parent, so a child cannot delegate rights that its creator does not hold.

Member and link permissions are stored on each share. Permission removals on a parent are propagated through the descendant branches created from that delegation. New permissions on a parent do not automatically expand existing descendant grants. Removing a member from a parent can also remove child shares owned through that delegation unless another effective membership still grants the required share permission.

The owner of an ancestor share retains management visibility over descendant shares. Removing a member who created child shares removes the branches owned through that delegation. Losing SHARE_OUTSIDE only blocks future delegation; existing child shares remain until explicitly removed or until their parent membership or permission propagation invalidates them.

Share links

A share link is represented by a link identity attached as a share member with its own effective permissions. Links created from a share are managed from that share rather than from the global list of file-origin links. Deleting the share removes its associated links together with the memberships that grant access.

Public-link validation combines the link and pseudo-user state. A link may be disabled, limited by an expiration date or access count, protected by a password, and associated with a recipient name, email, and language. Successful file downloads or folder accesses increment its access counter. Link permissions remain capped by the share permissions exactly like any other membership.

Deleting a share and deleting shared content

Deleting a share definition removes the share, its memberships, and its child share definitions. It does not delete the source content from the filesystem.

Deleting a file or directory while browsing shares/<share-alias>/... is a separate file operation. It follows the storage provenance of the shared content rather than the authenticated actor or the owner of the share record.

The shares/<share-alias> endpoint itself is virtual and cannot be deleted by a file operation; only its descendants can be deletion targets. Selecting permanent deletion does not bypass the effective DELETE permission or lock conflict checks.

Shared-content deletion policy

Shared content Deletion target
Personal files The source owner's managed user trash
Native-space files The source space's managed trash
External root attached to a native space The source space's managed trash
External share Permanent deletion
Child or other descendant of an external share Permanent deletion

The permanent-deletion rule is selected when the resolved space is in the shares repository and its root has an externalPath, unless its provenance points to a native space. It applies regardless of whether the actor is a regular user, guest, or link pseudo-user.

For an external share, deleting shared content:

  1. removes the resource directly from the external filesystem;
  2. permanently removes the corresponding file records from the database;
  3. removes associated locks;
  4. emits a DELETE_PERMANENTLY event.

The operation never uses the actor's home, a share-record owner's home, or an <external-root>/.trash/ directory. There is no fallback destination and no migration from an existing .trash directory.

Because no managed trash entry is created, deleted external-share content cannot be listed, restored, or removed later by the trash retention scheduler. If the external location cannot be modified, the deletion fails instead of redirecting the resource to another storage owner.

Future external trash support

The permanent-deletion rule is the current policy until external trash is implemented as a first-class repository. Such a repository must be explicitly addressable by the file browser and must define empty, restore, and retention lifecycles before external-share deletion can target it.

The managed trash layout and lifecycle are specified in spaces.md.