Skip to content

Stable record identity across versions, alongside hash-based file identity #66499

Description

@rubenvdlinde

Tip

Help move this idea forward

  • Use the 👍 reaction to show support for this feature.
  • Avoid commenting unless you have relevant information to add; unnecessary comments create noise for subscribers.
  • Subscribe to receive notifications about status changes and new comments.

Is your feature request related to a problem? Please describe.

Shares, tags, comments, metadata and /f/ links all key on fileid, the auto-increment id of oc_filecache. It survives renames and moves in current code, also across storages. It does not survive a cache rebuild, a rescan of external storage after cache loss, or a migration to another instance. On primary object storage the objects are named urn:oid:<fileid>, so the object only has an identity because of a database row.

This has bitten users before: file ids on external storage kept changing and broke share links (#31373), and moving folders in or out of a share on object storage changed the file id and lost shares and favourites (#31870). With #59345 (encryption keys stored by file id) the file id is becoming even more load-bearing.

For working material this is an inconvenience. For records that must stay referenceable for decades, for example from published decisions or answers to freedom-of-information requests, it is a defect.

Describe the solution you'd like

  1. A durable id per file next to fileid (a UUID), kept on rename and move, also across storages. A copy gets a new one.
  2. A storage backend may supply this id itself, for example from its own record identifier. Nextcloud uses it in preference to generating one.
  3. Where Nextcloud generates the id, it writes it to the backend when it can (object metadata on S3), so a rescan finds it back.
  4. The id resolves to the current location: /f/<id>, a WebDAV property, and a lookup in the public API.

As a first step shares and tags keep keying on fileid. The durable id is added and exposed first; moving associations onto it can follow.

Describe alternatives you've considered

  • oc:id. It is unique across instances, but it is built from fileid plus the instance id (DavUtil::getDavFileId), so it breaks in exactly the same cases.
  • Storing a UUID as files metadata. It has no uniqueness guarantee or lookup index, and it is lost with the cache unless it also lives in the backend.
  • Leaving it to apps. Every app would invent its own, and none of them could recover it after a rescan.

Additional context

Related to #66498 (deletion events should carry this id) and #66355 (metadata shown on the object should name this id). We (Conduction) would like to build and maintain this, with tests.

Activity

  1. susnux commented on Nov 10, 2026

    @susnux
    Contributor

    The file id should already be stable, if it is not then this is a bug that must be fixed.
    What is out of scope is moving files outside of Nextcloud, this cannot be tracked.

    does not survive a cache rebuild

    There is no "cache" to rebuild, filecache is not a cache its the main file system table of Nextcloud.
    Truncating it is basically resetting you Instance and must never be performed.

    a rescan of external storage after cache loss

    Similar here a "cache" loss is basically the same as completely dropping your filesystem - the solution here is rollback to your backup.

    a migration to another instance

    Not sure what this means, if you migrate your instance you always also have to migrate your existing database.

  2. rubenvdlinde commented on Nov 17, 2026

    @rubenvdlinde
    Author

    Thanks @susnux, that's a fair correction. I used "cache" loosely and agree: filecache is the file system table, and losing it means restoring a backup, not something to design for. I'll update the title and description of this issue.

    Two things remain.

    1. A case where file ids change. While testing #66498 we found one on an external S3 mount: when the bucket refuses the deletes (a policy denying s3:DeleteObject), deleting a folder returns 204, nothing is deleted, and after the rescan of the mount the folder's files come back with new file ids (106–109 became 110–113). We saw that with the trashbin enabled and disabled. Shares and tags on the old ids are gone. Following your point that unstable file ids are a bug, the details are in #66498, since the cause is the same: batchDelete() never reads the per-key errors.

    2. One id per record across versions. Ferdinand told us hash-based file identity is planned for this cycle. We welcome that: archives need a fixity value per version to show a file is unchanged. They also need an id that stays the same when a new version is saved, so a decision or a published reference keeps pointing at the same record. Is that part of the planned design, or is the hash per version only? If it is per version, we'd like to discuss a stable record id next to it rather than build something separate.

  3. changed the title [-]Durable object identity that survives a cache rebuild[/-] [+]Stable record identity across versions, alongside hash-based file identity[/+] on Nov 17, 2026
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

    0. Needs triagePending check for reproducibility or if it fits our roadmapenhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions