Skip to content

Expose LOCK response ETag on NKLock - #249

Merged
marinofaggiana merged 1 commit into
mainfrom
copilot/update-nklock-etag-property
Aug 24, 2026
Merged

Expose LOCK response ETag on NKLock#249
marinofaggiana merged 1 commit into
mainfrom
copilot/update-nklock-etag-property

Conversation

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

NKLock did not surface the resource ETag already returned by successful WebDAV LOCK responses, forcing callers to operate without metadata that was already available in the response body. This change keeps the existing lock/unlock flow intact and makes the parsed LOCK ETag available directly on the lock model.

  • Model update

    • Add etag: String? to NKLock.
    • Parse d:getetag from the existing LOCK XML payload in NKLock.init(xml:).
    • Normalize the value by stripping surrounding double quotes, matching existing ETag handling elsewhere in the library.
    • Extend the raw-value initializer with a trailing etag parameter defaulting to nil to preserve source compatibility.
  • Parsing behavior

    • Missing d:getetag continues to produce a valid NKLock.
    • Unquoted ETags are preserved as-is.
    • No additional WebDAV request is introduced.
  • Unit coverage

    • Add NKLockUnitTests for:
      • quoted ETag parsing and normalization,
      • missing ETag behavior,
      • unquoted ETag preservation,
      • lock token parsing from a valid LOCK response.
let lock = NKLock(data: lockResponseData)
let etag = lock?.etag // "etag-after-lock"

Co-authored-by: Rello <13385119+Rello@users.noreply.github.com>
@i2h3
i2h3 requested a balanced review from Copilot August 24, 2026 10:25
@i2h3 i2h3 added the bug Something isn't working label Aug 24, 2026
@i2h3 i2h3 moved this to 🏗️ In progress in 💻 Desktop Clients team Aug 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Exposes normalized LOCK response ETags through NKLock without changing request behavior.

Changes:

  • Adds optional etag parsing and raw initialization support.
  • Adds tests for quoted, unquoted, and missing ETags.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Sources/NextcloudKit/Models/NKLock.swift Adds and populates the optional ETag property.
Tests/NextcloudKitUnitTests/NKLockUnitTests.swift Covers LOCK token and ETag parsing behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@marinofaggiana
marinofaggiana merged commit 7ad6413 into main Aug 24, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from 🏗️ In progress to ☑️ Done in 💻 Desktop Clients team Aug 24, 2026
@Rello
Rello deleted the copilot/update-nklock-etag-property branch August 24, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: ☑️ Done

Development

Successfully merging this pull request may close these issues.

5 participants