opencloud icon indicating copy to clipboard operation
opencloud copied to clipboard

`revisions purge` skips POSIXFS revisions with whole-second timestamps

Open Sympatron opened this issue 3 weeks ago • 1 comments

Describe the bug

On POSIXFS, opencloud revisions purge fails to detect valid revision filenames without fractional seconds, including numbered revisions:

  • *.REV.2022-10-14T10:42:55Z
  • *.REV.2022-10-14T10:42:55Z.1

The regex in opencloud/pkg/revisions/revisions.go requires fractional seconds, although POSIXFS can create revisions without them and append .1, .2, etc. for timestamp collisions.

Steps to reproduce

  1. Use POSIXFS and upload/overwrite files with whole-second modification timestamps, e.g. through WebDAV.
  2. Confirm that .oc-nodes contains revisions with the filenames above.
  3. Run:
opencloud revisions purge -p /var/lib/opencloud/storage/users --blobstore=none --glob-mechanism=list --dry-run=true
  1. Observe that these revisions are not detected.

Expected behavior

All valid POSIXFS revision filename formats should be recognized and purged, including whole-second timestamps and numbered suffixes.

Actual behavior

In my case, purging deleted 3,282 files but left 4,931 revision files (105 GiB) behind.

Setup

  • OpenCloud: 9.0.0
  • Deployment: Docker Compose
  • Storage backend: POSIXFS
  • Storage path: /var/lib/opencloud/storage/users
  • Filesystem: Local filesystem with bind-mounted persistent storage
  • Affected files: Revisions under projects/<space-id>/.oc-nodes/
  • Migration source: Nextcloud via rclone/WebDAV

Additional context

This issue was partially written by AI, but the problem was manually verified on my system. I "fixed" it by manually deleting those files.

Sympatron avatar Nov 10 '26 08:11 Sympatron

Hi @Sympatron @aduffeck, can I do it?

How I plan to do it:

  1. In opencloud/pkg/revisions/revisions.go, make the fraction in _versionRegex optional: \.REV\.[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?Z. Glob, GlobWorkers, Walk and PurgeRevisions all use it, so one change covers them.
  2. The .1 / .2 collision suffix then falls into the default (revision) branch of PurgeRevisions, so no change there. Add the whole-second and numbered forms to the comment above the regex.
  3. Tests in revisions_test.go: X.REV.2022-10-14T10:42:55Z, ...Z.1 and ...Z.mpk are found by the glob/walk paths and counted by a PurgeRevisions dry run.
  4. Must not change: the existing fractional-second cases, and a name like X.REV.garbage is still ignored.
  5. go test ./opencloud/pkg/revisions/....

Open question: should the regex match the .N suffix explicitly, or is "anything after Z" fine like today?

RyoKusnadi avatar Nov 12 '26 15:11 RyoKusnadi