Skip to content

feat(ios): keep owed originals across relaunch, sign-out, and purge - #230

Merged
altaywtf merged 2 commits into
nextfrom
feat/offline-remove-original-2
Sep 13, 2026
Merged

altaywtf merged 2 commits into
nextfrom
feat/offline-remove-original-2

Conversation

@altaywtf

Copy link
Copy Markdown
Member

Problem

After #229, an original the user asked put.io to take is only remembered in memory. If iOS suspends or kills the app while the request is in flight, or after a failure but before the report is handled, the next launch has no queue item and no retry target: the original stays on put.io with no trace of the request.

Refs #106. Second of three stacked PRs on top of #229.

Solution

  • Originals put.io has not answered for are persisted in the queue document as pendingOriginals, written in the same document update as the local removal, so no kill can record one without the other. restore() retries them on the next launch and surfaces failures in the report. OK gives them up; Try again keeps them owed. One debt per file: a newer confirmation replaces the older name and mode.
  • purgeAccountStorage() (Clear Data, Destroy Account) drops owed originals and the report and ends requests in flight without writing.
  • A queue whose session has ended (the session's authentication generation moved on) starts no original work and writes nothing, so a late answer never overwrites the next shell's document. PutioSessionStore.authenticationGeneration becomes public for that.

Proof

  • mise run verify, mise run harness -- test --platform ios, and mise run harness -- journey --platform ios --scenario files-browser passed locally on this commit.
  • OfflineDownloadsTests cover pending originals surviving a relaunch and being given up on dismissal, retry keeping them owed, a purge ending in-flight requests, a queue whose session ended writing nothing, and a newer confirmation replacing the debt for the same file.

Copilot AI lite review requested due to automatic review settings September 13, 2026 05:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 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-13T06:42:42.376385Z b1c6ecd 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.

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.

🟡 Changes recommended

A stale queue can still persist pending-original state via dismiss/settle paths without checking isLive(), which can violate the “writes nothing after session end” guarantee and risk overwriting a successor shell’s document.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR makes “delete remote original” requests durable in the iOS offline-downloads queue by persisting owed deletions (pendingOriginals) and ensuring the queue won’t let a stale signed-in shell overwrite state after a session boundary.

Changes:

  • Persist owed remote-original deletions in queue.json and retry them on next launch via restore().
  • Add session-liveness gating for original-deletion work using PutioSessionStore.authenticationGeneration.
  • Expand OfflineDownloadsTests to cover relaunch survival, dismissal/retry behavior, purge behavior, and session-end behavior.
File summaries
File Description
Tests/iOS/Sources/OfflineDownloadsTests.swift Adds coverage for pending-original persistence, session-end behavior, and purge/in-flight handling.
Packages/PutioCore/Sources/PutioCore/Session/PutioSessionStore.swift Makes authenticationGeneration publicly readable to support session-bound work.
Apps/iOS/Sources/PutioApp.swift Captures a session generation and wires isLive into the offline queue factory.
Apps/iOS/Sources/OfflineRemoval.swift Makes PutioOfflineRemovalTarget Codable so pending originals can be persisted.
Apps/iOS/Sources/OfflineDownloads.swift Implements pendingOriginals persistence, restore-time retry, and liveness/purge safety for original deletions.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread Apps/iOS/Sources/OfflineDownloads.swift

@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: d243fd399c

ℹ️ 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 Apps/iOS/Sources/OfflineDownloads.swift Outdated
Comment thread Apps/iOS/Sources/OfflineDownloads.swift Outdated
Comment thread Apps/iOS/Sources/OfflineDownloads.swift
Base automatically changed from feat/offline-remove-original-1 to next September 13, 2026 05:43
Originals put.io has not answered for are persisted in the queue document
in the same write as the local removal and retried on the next launch.
Dismissing the report gives them up; retrying keeps them owed. A purge
ends requests in flight, and a queue whose session ended writes nothing.

Refs #106
@altaywtf
altaywtf force-pushed the feat/offline-remove-original-2 branch from d243fd3 to 30e74d3 Compare September 13, 2026 05:44

@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: 30e74d3ac1

ℹ️ 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 Apps/iOS/Sources/OfflineDownloads.swift Outdated
Comment thread Apps/iOS/Sources/OfflineDownloads.swift
Comment thread Apps/iOS/Sources/OfflineDownloads.swift
…, and keep a newer debt over a stale request

Every document write is refused once the owning session ended. The debt
is written before the package is deleted and an interrupted removal is
finished on the next launch. Downloading the file again supersedes its
debt. A stale request that completes or fails never replaces the newer
confirmation for the same file or its failure report.

@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: b1c6ecdc81

ℹ️ 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 Apps/iOS/Sources/OfflineDownloads.swift
Comment thread Apps/iOS/Sources/OfflineDownloads.swift
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.

2 participants