`revisions purge` skips POSIXFS revisions with whole-second timestamps
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
- Use POSIXFS and upload/overwrite files with whole-second modification timestamps, e.g. through WebDAV.
- Confirm that .oc-nodes contains revisions with the filenames above.
- Run:
opencloud revisions purge -p /var/lib/opencloud/storage/users --blobstore=none --glob-mechanism=list --dry-run=true
- 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.
Hi @Sympatron @aduffeck, can I do it?
How I plan to do it:
- In
opencloud/pkg/revisions/revisions.go, make the fraction in_versionRegexoptional:\.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,WalkandPurgeRevisionsall use it, so one change covers them. - The
.1/.2collision suffix then falls into the default (revision) branch ofPurgeRevisions, so no change there. Add the whole-second and numbered forms to the comment above the regex. - Tests in
revisions_test.go:X.REV.2022-10-14T10:42:55Z,...Z.1and...Z.mpkare found by the glob/walk paths and counted by aPurgeRevisionsdry run. - Must not change: the existing fractional-second cases, and a name like
X.REV.garbageis still ignored. go test ./opencloud/pkg/revisions/....
Open question: should the regex match the .N suffix explicitly, or is "anything after Z" fine like today?