Skip to content

Add failed-upload retention cleanup and legal warning banners - #3

Merged
wickedyoda merged 1 commit into
mainfrom
feature/ghcr-ci-and-upload-improvements
Apr 12, 2026
Merged

Add failed-upload retention cleanup and legal warning banners#3
wickedyoda merged 1 commit into
mainfrom
feature/ghcr-ci-and-upload-improvements

Conversation

@wickedyoda

Copy link
Copy Markdown
Owner

Summary

  • keep partial files for failed uploads for 2 minutes before cleanup
  • add POST /api/upload/fail/:uploadId to mark failed uploads for delayed cleanup
  • add periodic failed-upload cleanup worker and env toggle (DISABLE_FAILED_UPLOAD_CLEANUP)
  • update upload client to mark failed uploads instead of immediate cancellation on non-user errors
  • add top and bottom legal warning/disclaimer links on upload page
  • add regression test for failed upload retention window and cleanup timing

Verification

  • static error check in edited files: no errors
  • runtime tests could not be executed in this environment because node is not available (command not found)

Copilot AI review requested due to automatic review settings April 12, 2026 22:13
@wickedyoda
wickedyoda merged commit bf7c3dc into main Apr 12, 2026
4 checks passed
@wickedyoda
wickedyoda deleted the feature/ghcr-ci-and-upload-improvements branch April 12, 2026 22:13

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.

Pull request overview

Adds a failed-upload retention flow (mark-as-failed endpoint + periodic cleanup) and surfaces legal warning banners on the upload page, with a regression test for retention timing.

Changes:

  • Introduces POST /api/upload/fail/:uploadId, a failed-upload retention window constant, and a periodic cleanup worker gated by DISABLE_FAILED_UPLOAD_CLEANUP.
  • Updates the upload client to mark uploads as failed on non-user errors (instead of immediate server cancellation).
  • Adds top/bottom legal warning banners to the upload UI, plus a test validating retention and cleanup behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/routes/upload.js Adds failed-upload retention state, cleanup worker, and /fail endpoint; clears failed marker on resumed chunk uploads.
test/upload.test.js Adds regression test validating failed-upload retention and cleanup timing via exported helpers.
public/index.html Adds legal warning banners and switches client failure handling to call the new /fail endpoint.
public/styles.css Styles the new legal warning banners and adjusts responsive sizing.
.env.example Documents DISABLE_FAILED_UPLOAD_CLEANUP toggle.

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

Comment thread src/routes/upload.js
Comment on lines +450 to +451
// Upload resumed after failure; clear failed marker so cleanup won't remove active data.
delete metadata.failedAt;

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

In the chunk handler, metadata.failedAt is cleared in-memory but isn’t persisted until after the chunk write. The failed-upload cleanup interval can race with an upload resuming and delete the partial file/metadata during this window (worst case: the file is deleted and then re-created by fs.open(..., 'a'), corrupting the upload). Persist the cleared failedAt (and/or set an explicit active state) before any file operations, and/or have the cleanup worker also gate deletion on lastActivity being older than the retention window.

Suggested change
// Upload resumed after failure; clear failed marker so cleanup won't remove active data.
delete metadata.failedAt;
// Upload resumed after failure; clear failed marker and persist activity
// before any file operations so cleanup logic cannot race and delete
// the partial upload based on stale on-disk metadata.
delete metadata.failedAt;
metadata.lastActivity = new Date().toISOString();
await writeUploadMetadata(uploadId, metadata);

Copilot uses AI. Check for mistakes.
Comment thread test/upload.test.js
Comment on lines 16 to 19
// Import the app
const { app, initialize, config } = require('../src/app');
const { readUploadMetadata, cleanupFailedUploads, FAILED_UPLOAD_RETENTION_MS } = require('../src/routes/upload');

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

The upload routes module now starts the failed-upload cleanup interval on import. This test file disables batch cleanup, but doesn’t disable failed-upload cleanup, so the background interval can make the new retention test flaky on slow runs (it may delete the partial/metadata based on wall clock time). Consider setting process.env.DISABLE_FAILED_UPLOAD_CLEANUP = 'true' in tests (and/or calling stopFailedUploadCleanup() in teardown) and invoking cleanupFailedUploads(...) explicitly when needed.

Copilot uses AI. Check for mistakes.
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