Skip to content

fix: handle negative lock timeout (ETA_INFINITE sentinel) from files_lock#17069

Draft
moodyjmz wants to merge 2 commits into
masterfrom
fix/lock-timeout-negative-sentinel
Draft

fix: handle negative lock timeout (ETA_INFINITE sentinel) from files_lock#17069
moodyjmz wants to merge 2 commits into
masterfrom
fix/lock-timeout-negative-sentinel

Conversation

@moodyjmz
Copy link
Copy Markdown
Contributor

Summary

  • When files_lock is configured with infinite timeout (the default, -1 minutes), it sends nc:lock-timeout=-60 via WebDAV PROPFIND
  • getLockedUntil() was computing (lockTimestamp + lockTimeout) * MILLIS_PER_SECOND without guarding against negative timeout values, resulting in a date in the past
  • This caused the UI to show "Expires: 1 minute ago" on actively locked files

The guard was changed from file.lockTimeout == 0L to file.lockTimeout <= 0L so any non-positive timeout (including the -60 sentinel) correctly returns null (no expiry shown).

The root cause fix is server-side in files_lock (see related PR). This is a defensive client-side guard for servers that haven't been updated yet.

Test plan

  • FileActionsViewModelTest — 4 unit tests covering lockTimeout == 0, lockTimeout < 0 (-60 sentinel), lockTimestamp == 0, and positive values
  • Open a file locked with infinite timeout on an unpatched server and verify no expiry label is shown

🤖 Generated with Claude Code

@moodyjmz moodyjmz self-assigned this May 19, 2026
moodyjmz and others added 2 commits May 19, 2026 23:09
When files_lock is configured with the default infinite timeout (-1 min),
the server sends nc:lock-timeout=-60 via PROPFIND. The previous guard only
checked for == 0, causing getLockedUntil() to compute a timestamp 60s in
the past, making the lock appear expired immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Cover zero, negative (-60 sentinel), zero timestamp, and positive timeout
cases for getLockedUntil().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
@moodyjmz moodyjmz force-pushed the fix/lock-timeout-negative-sentinel branch from cc8bab1 to d1c34f0 Compare May 19, 2026 21:09
@github-actions
Copy link
Copy Markdown

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions
Copy link
Copy Markdown

Codacy

SpotBugs

CategoryBaseNew
Bad practice3535
Correctness6767
Dodgy code216216
Experimental11
Internationalization77
Malicious code vulnerability22
Multithreaded correctness3434
Performance4242
Security1616
Total420420

@github-actions
Copy link
Copy Markdown

APK file: https://github.com/nextcloud/android/actions/runs/26125491810/artifacts/7098404610
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

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