Skip to content

Support nested serverFolder paths with automatic creation - #2309

Merged
marcelklehr merged 4 commits into
floccusaddon:developfrom
clemenstyp:serverfolder-as-nested-path
Jul 25, 2026
Merged

Support nested serverFolder paths with automatic creation#2309
marcelklehr merged 4 commits into
floccusaddon:developfrom
clemenstyp:serverfolder-as-nested-path

Conversation

@clemenstyp

Copy link
Copy Markdown
Contributor

Summary

This PR extends how the serverFolder is resolved when building the
bookmarks tree.

Until now, the code only looked for a single top-level collection whose
name exactly matched serverFolder. If none was found, it created one
flat root collection. Nested folder paths were not supported.

Changes

  • Exact match first: Keeps the existing behavior of matching the full
    serverFolder name against a root-level collection.
  • Path resolution fallback: If no exact match exists, serverFolder
    is split on / and each segment is resolved sequentially from the root
    downwards. The parent of each segment must be the previously matched
    collection.
  • Auto-creation of missing segments: Any segment that does not yet
    exist is created via POST /api/v1/collections (with the correct
    parentId) and added to the local collection list so buildTree can
    use it.
  • isRoot handling: The deepest (target) collection is always passed to
    buildTree with isRoot = true.

Behavior

Case Result
Full name exists as root Used directly
Path partially exists (e.g. a/b exists, c missing) a, b reused, c created
Path does not exist at all All segments created sequentially

Notes

  • Parent comparisons are normalized to strings to avoid number/string
    mismatches.

Previously, only an exact top-level match for `serverFolder` was
supported, falling back to creating a single root collection.

Now, if no exact match is found, `serverFolder` is treated as a
`/`-separated path. Each segment is resolved from root downwards,
and any missing segments are created on the fly. This allows the
root bookmark folder to live at an arbitrary depth in the
collection hierarchy.

The resolved (deepest) collection is passed to buildTree with
isRoot = true.
@marcelklehr

Copy link
Copy Markdown
Member

Awesome! Thanks for the contribution!

@marcelklehr
marcelklehr requested a review from Copilot July 24, 2026 08:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Extends serverFolder resolution to support nested collection paths, creating missing Linkwarden collections on demand when building the bookmarks tree.

Changes:

  • Keeps existing exact root-level name match for serverFolder.
  • Falls back to resolving /-delimited path segments from the root downward.
  • Auto-creates missing collections with correct parentId and updates the in-memory collections list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/adapters/Linkwarden.ts
Comment thread src/lib/adapters/Linkwarden.ts Outdated
Comment thread src/lib/adapters/Linkwarden.ts Outdated
Comment thread src/lib/adapters/Linkwarden.ts Outdated
Comment thread src/lib/adapters/Linkwarden.ts Outdated
@marcelklehr
marcelklehr merged commit cae1fcd into floccusaddon:develop Jul 25, 2026
@marcelklehr

Copy link
Copy Markdown
Member

Thank you!

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.

3 participants