Skip to content

fix(files): recover folder grant ownership - #445

Open
veryCrunchy wants to merge 75 commits into
fix/durable-upload-scheduling-recovery-stackfrom
fix/filesync-capability-lifecycle
Open

fix(files): recover folder grant ownership#445
veryCrunchy wants to merge 75 commits into
fix/durable-upload-scheduling-recovery-stackfrom
fix/filesync-capability-lifecycle

Conversation

@veryCrunchy

Copy link
Copy Markdown
Member

Summary

  • Track Android SAF folder grants through selection, pairing, removal, and restart recovery.
  • Reconcile ambiguous pair/account retirement failures without losing permission cleanup.
  • Retry grant release and remove orphaned upload-cleanup rows while preserving other accounts.
  • Keep restored file-sync screens backed by live state instead of a disposed snapshot.

Validation

  • Full repository checks passed.
  • Build host: 99 focused Android tests and 1 UI lifecycle test passed.
  • Build host: :androidApp:assembleDebug passed.
  • Exact post-rebase tree: 166f3d4910a3c657166040d753bfa387e7ac7014.

@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 5, 2026 15:21 Destroyed
@obiente-cloud

obiente-cloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

Obiente preview

NC Native · edc9e8e9b203 · Ready

Open preview

View in Obiente

Obiente updates this comment as the preview changes.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-06T07:24:18.576364Z 1cd6faa New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 5, 2026 15:21 Destroyed
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 5, 2026 15:29 Destroyed
@veryCrunchy
veryCrunchy force-pushed the fix/durable-upload-scheduling-recovery-stack branch from 7dfaeb8 to d963ee4 Compare September 5, 2026 22:42
@veryCrunchy
veryCrunchy force-pushed the fix/filesync-capability-lifecycle branch from 8536f7f to dfecb8d Compare September 5, 2026 22:44
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 5, 2026 22:44 Destroyed
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 5, 2026 22:49 Destroyed
@veryCrunchy
veryCrunchy force-pushed the fix/durable-upload-scheduling-recovery-stack branch from d963ee4 to b2c2188 Compare September 5, 2026 23:01
@veryCrunchy
veryCrunchy force-pushed the fix/filesync-capability-lifecycle branch from 03d8e39 to 3d48cc7 Compare September 5, 2026 23:02
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 5, 2026 23:02 Destroyed
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 5, 2026 23:05 Destroyed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d48cc7639

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread androidApp/src/main/kotlin/dev/obiente/nextcloudnative/AndroidFileSyncEngine.kt Outdated
@veryCrunchy
veryCrunchy force-pushed the fix/durable-upload-scheduling-recovery-stack branch 3 times, most recently from 6057f39 to a712498 Compare September 6, 2026 04:47
@veryCrunchy
veryCrunchy force-pushed the fix/filesync-capability-lifecycle branch from f26e9a4 to 3f91e1b Compare September 6, 2026 04:47
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 6, 2026 04:47 Destroyed
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 6, 2026 04:55 Destroyed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f91e1bfab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@veryCrunchy
veryCrunchy force-pushed the fix/durable-upload-scheduling-recovery-stack branch 3 times, most recently from cc5f869 to 337b65f Compare September 6, 2026 05:49
@veryCrunchy
veryCrunchy force-pushed the fix/filesync-capability-lifecycle branch from bde44c3 to ec6875c Compare September 6, 2026 05:57
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 6, 2026 05:57 Destroyed
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 6, 2026 06:02 Destroyed
@veryCrunchy
veryCrunchy force-pushed the fix/durable-upload-scheduling-recovery-stack branch from 337b65f to 4cfb960 Compare September 6, 2026 07:04
@veryCrunchy
veryCrunchy force-pushed the fix/filesync-capability-lifecycle branch from 6be731b to 36a8f5b Compare September 6, 2026 07:11
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 6, 2026 07:11 Destroyed
@veryCrunchy
veryCrunchy force-pushed the fix/durable-upload-scheduling-recovery-stack branch from 54c77f1 to 30d6eb1 Compare September 6, 2026 07:14
@veryCrunchy
veryCrunchy force-pushed the fix/filesync-capability-lifecycle branch from 36a8f5b to 1cd6faa Compare September 6, 2026 07:16
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #445 / NC Native September 6, 2026 07:16 Destroyed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1cd6faadc4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +313 to +314
} else {
check(prepareAndFinishCleanup(record)) { CLEANUP_RETRY_MESSAGE }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep restored setup roots valid through restart

When Android kills the process while the add-folder dialog is open, rememberSaveable restores the SAF URI, but startup reaches this branch because the capability has an old process generation and no committed pair, releasing the grant and removing its record. The restored dialog then points at an unusable capability, so adding the pair races reconciliation and typically fails while dismissal can leave the draft stuck. Unlike the earlier activity-recreation comment, the fresh evidence is this new old-generation cleanup path; either avoid saving the capability URI across process death or durably reattach the restored draft before reconciliation.

AGENTS.md reference: AGENTS.md:L245-L248

Useful? React with 👍 / 👎.

Comment on lines +59 to +60
fun abandon(localRootId: String): Boolean =
runCatching { capabilities.abandonSelection(localRootId) }.getOrDefault(false)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat non-SAF roots as already abandoned

When a user opens and dismisses a detected media suggestion, its root starts with media-store://, so it has no capability record and abandonSelection returns false. FileSyncSetupDraftState.abandon consequently retains that root while clearing its configuration, and beginAddFolderSync then refuses to open the native picker because every cleanup retry returns false. Return success for roots that never use SAF grants while reserving false for an actual pending cleanup.

Useful? React with 👍 / 👎.

@veryCrunchy
veryCrunchy force-pushed the fix/durable-upload-scheduling-recovery-stack branch 6 times, most recently from bcae385 to 1caca52 Compare September 6, 2026 12:32
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