Skip to content

fix(View): safer lock life-cycle handling in basicOperation() + clearer control flow #58947

Draft
joshtrichards wants to merge 6 commits intomasterfrom
jtr/refactor-View-basicOperation
Draft

fix(View): safer lock life-cycle handling in basicOperation() + clearer control flow #58947
joshtrichards wants to merge 6 commits intomasterfrom
jtr/refactor-View-basicOperation

Conversation

@joshtrichards
Copy link
Member

  • Resolves: #

Summary

Key changes:

  • Remove unconditional unlock paths; only unlock locks were actually acquired
    • Most flows were already correct; this closes remaining edge cases and reduces lock-handling boilerplate.
  • Improve readability and maintainability of basicOperation().

Safer lock lifecycle handling:

  • Add explicit lock-state tracking (using ILockingProvider lock constants).
  • Centralize unlock handling in finally for consistent cleanup on both success and error paths.
  • Preserve special fopen behavior:
    • lock ownership is transferred to the wrapped stream close callback,
    • finally skips unlock when ownership is transferred.

Refactoring:

  • Rework control flow with clearer guard clauses and inline comments.
  • Extract hook intent flags (read/write/delete/touch/create) into local booleans.
  • Update method docblock with stricter parameter/behavior notes and and explicit flow documentation.

This is primarily a maintainability/safety refactor with no intended functional change.

The previous structure made lock transitions and cleanup paths harder to reason about; this makes lock ownership and release paths explicit and lowers regression risk.

Review tip: Easiest to review commit-by-commit

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
use lock-state tracking + centralized finally cleanup

Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added this to the Nextcloud 34 milestone Mar 14, 2026
@joshtrichards joshtrichards added bug feature: filesystem feature: locking ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Mar 14, 2026
Signed-off-by: Josh <josh.t.richards@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug feature: filesystem feature: locking ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant