Skip to content

Restoring a namespace child before its parent loses the parent #1350

Closed
logseq/logseq
#13514

Description

@yuxi-liu-wired

Steps

  1. Press Cmd+K (Ctrl+K), type "Foo/Bar", and create the page.
  2. Delete the page Bar, then delete the page Foo.
  3. Open the Recycle page. Restore Bar first, then Foo.

Expected

Foo/Bar is back as it was: Bar under Foo in the Library. Restoring Foo first and Bar second gives that.

Actual

Bar is back as a top-level page with no parent, and Foo is back without Bar under it.

Cause

restore-target (deps/outliner/src/logseq/outliner/recycle.cljs) keeps the original parent only when that parent is live and not in the Recycle; for a page whose parent is in the Recycle it returns no parent, and restore-tx-data retracts :block/parent. It also retracts :logseq.property.recycle/original-parent with the other recycle attributes, so when the parent comes back later nothing records that Bar belonged under it.

Found by the page model property test (frontend.worker.page-model-property-test, branch test/page-model-fuzz) on upstream master 16c4ed1a0, with the check "trash then restore is identity", run with a page and its namespace parent, restored in either order. Shortest sequence: FUZZ_REPLAY='[[:create 5 0 0] [:trash 0 3 1]]'. With [:trash 0 3 0] (the parent restored first) the graph comes back unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions