Skip to content

feat: add file content replacement - #155

Merged
PANiXiDA merged 26 commits into
developmentfrom
feature/update-file-content
Nov 20, 2026
Merged

PANiXiDA merged 26 commits into
developmentfrom
feature/update-file-content

Conversation

@PANiXiDA

@PANiXiDA PANiXiDA commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Adds PUT /api/v1/files/{id}/content (multipart File, 204) using existing Personal .own/.all and Avatar update permissions. File identity, name, type, owner, folder and S3 key stay unchanged.

Persist Updating, the active S3 VersionId and a unique ContentUpdateAttemptId before uploading. Upload to the same key with content-update-attempt-id metadata, then inspect the exact version returned by S3 and save its verified ContentType, Size and VersionId. The shared metadata key comes from Core Application's Storage.Constants.FileMetadataNames; the local constant is removed. FileContentUpdatePolicy.CanAccept shares operation, version and stored-metadata validation between the handler and worker; request-specific ContentType and Size checks stay in the handler. Download URLs are pinned to the active version, including during Updating. Rename, move, delete and another content update conflict until the attempt completes or expires. Optimistic concurrency and the expected operation ID fence stale requests.

The existing worker first inspects current content and, when necessary, enumerates versions of the exact key to find the matching operation. This recovers lost upload responses and failed final database saves even when a cancelled upload finishes later and becomes S3's latest version. After ExpirationAge, an attempt with no valid matching version is cancelled and the previous active version remains Ready. Storage inspection/list failures leave the attempt for retry. The deployment has no existing file records. Every successful initial upload stores its version before becoming Ready; updates and download URLs use that stored version directly. The nullable version column accommodates PendingUpload records. No existing-file version discovery or backfill is needed. Download URL requests with an unexpectedly missing active version return 409 explicitly without inspecting S3.

Updates Application Core to 6.3.1 and S3 Core to 1.3.1. Adds nullable active-version and operation-ID columns; removes temporary replacement keys and their cleanup scheduler. Requires bucket versioning and S3 permissions for version reads and version listing (GetObjectVersion, ListBucketVersions). Retain the DB-active version even when it is no longer S3's latest; a blanket noncurrent-version expiration rule can remove active content. The existing delete operation retains its delete-marker semantics.

Validation covers domain lifecycle/fencing, reservation concurrency, persistence/migrations, endpoint permissions, version-bound downloads, identical-byte replacement, lost responses, delayed cancelled uploads and reconciliation behind a newer unrelated version. All tests, formatting and Sonar Quality Gate pass on 9910ee8 (CI run 44596324453). The HTTP regression test covers a Ready record with a missing active version. The first attempt started before NuGet indexed 6.3.1; dependency restoration succeeds after indexing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T04:53:13.907971Z 9910ee8 Manual request
ℹ️ 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.

@PANiXiDA

Copy link
Copy Markdown
Contributor Author

@codex

@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: 05a583e0af

ℹ️ 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".

@PANiXiDA

Copy link
Copy Markdown
Contributor Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: a05fcb0ae2

ℹ️ 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".

@PANiXiDA

Copy link
Copy Markdown
Contributor Author

@codex

@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: 6d5403acea

ℹ️ 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".


var download = await fileStorage.GetPresignedDownloadUrlAsync(
key: file.StorageKey.Value,
versionId: file.VersionId!.Value,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Populate active versions before requiring them for downloads

On an existing deployment, AddFileContentUpdates adds a nullable version_id column without populating it, so every previously ready file retains a null VersionId. Those files pass GetDownloadContentType() and then throw NullReferenceException here, turning previously working download-URL requests into HTTP 500 responses. Repository-wide searches found no backfill, and upload reconciliation only processes pending uploads and content updates, not ready files. Populate and pin existing objects' versions before making this dereference mandatory, or provide a safe compatibility path until they are migrated.

Useful? React with 👍 / 👎.

@panixida-sonarqube

Copy link
Copy Markdown

@PANiXiDA

Copy link
Copy Markdown
Contributor Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 9910ee82f6

ℹ️ 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".

@PANiXiDA
PANiXiDA merged commit a832970 into development Nov 20, 2026
39 checks passed
@PANiXiDA
PANiXiDA deleted the feature/update-file-content branch November 20, 2026 04:56
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