Skip to content

feat(seed): add advanced transfer seed UI (generate/preview/manage) - #670

Open
PIKACHUIM wants to merge 21 commits into
mainfrom
feat/advanced-transfer-seeds
Open

feat(seed): add advanced transfer seed UI (generate/preview/manage)#670
PIKACHUIM wants to merge 21 commits into
mainfrom
feat/advanced-transfer-seeds

Conversation

@PIKACHUIM

Copy link
Copy Markdown
Member

title: Advanced Transfer Seeds — Implementation PR
categories: [guide, advanced]
top: 22

Advanced Transfer Seeds — Implementation PR

This document is the implementation pull-request description for the Advanced Transfer Seeds feature. It complements the design and compatibility specification in transfer-seeds.md and records what was actually implemented, how it was validated, and what remains out of scope.

1. Summary

Advanced Transfer Seeds add a portable, cross-driver, cross-user metadata system built on three sidecar formats:

  • .ossopenlist-sharing-seed v1 JSON. The most complete and lossless envelope; every field is optional except format, version, name, created_at, created_by, piece_size, and files.
  • .torrent — standard BitTorrent v1 plus a root-level x-openlist extension and a legacy-compatible x-cas extension. Always carries the SHA-1 piece hashes required by BT; additional MD5/SHA-256 and comments/sources live in the extension.
  • .cas — byte-for-byte compatible with the reference OpenList-CAS payload: padded Base64 of JSON containing exactly name, size, md5, sliceMd5, and create_time. No extension keys are added, preserving third-party client compatibility.

Users can generate seeds during upload or from the right-click context menu, preview and consume them, convert between formats, rapid-save into another driver, relay a save through an intermediate driver, and edit/recalculate metadata.

2. What is included

Repository Branch Scope
OpenList-Backends feat/advanced-transfer-seeds Go format library, /fs/seed/* API, upload sidecars, file-op sidecars, settings
OpenList-Frontend feat/advanced-transfer-seeds HopeUI generation wizard, seed preview, upload/file-op sidecar toggles, settings
OpenList-TSWorker feat/advanced-transfer-seeds TS codec and /fs/seed/* routes, streaming hashing, settings
OpenList-Docs docs/advanced-transfer-seeds Design spec, compatibility reference, and this PR document

Implemented capabilities:

  1. Generate — single or multiple files, three formats at once (oss, torrent, cas), a content hash matrix (md5/sha1/sha256 × whole/pieces), per-file and overall comments, trackers, channels, piece size, and optional share/direct-source embedding.
  2. Preflight — driver-provided hashes are reported so the UI can show whether files must be fetched before generation, and the estimated traffic.
  3. Preview/parse — unified parsing of .oss, .torrent, and .cas with files, hashes, comments, timestamps, trackers, channels, sources, conversion feasibility, and operation capabilities.
  4. Convert — between all three formats with explicit missing-information diagnostics; semantic projection is used instead of incorrect strict-subset claims.
  5. Rapid upload — native driver reuse (189pc CAS) when hashes are available; otherwise an explicit unavailable reason (never a silent generic upload).
  6. Offline download — authorized source URL into the destination driver via PutURL, an offline-download tool, or a server-side streamed transfer.
  7. Relayed transferoptions.mode: "transfer" with transit_path materializes synchronously into an intermediate storage (native rapid upload or PutURL), then copies server-side to the final destination. Asynchronous offline downloads are rejected for relay.
  8. Edit — update the overall comment, trackers, channels, per-file comments, and per-file share/direct sources; sources are validated against the configured site URL.
  9. Recalculate — re-read server-side files (bounded to 1 GiB) and recompute whole and piece hashes using a supplied matrix; the piece size is validated and written back to the seed.
  10. Sidecar lifecycle — upload, copy, move, rename, and delete can optionally manage .oss/.torrent/.cas sidecars alongside the source file.

3. Format specification

.oss (openlist-sharing-seed v1)

{
  "format": "openlist-sharing-seed",
  "version": 1,
  "name": "example",
  "comment": "",
  "created_at": "2026-09-08T00:00:00Z",
  "created_by": "OpenList",
  "piece_size": 10485760,
  "trackers": [],
  "channels": [{"driver": "189pc", "mount_path": "/189pc"}],
  "files": [
    {
      "path": "a.txt",
      "size": 12,
      "modified": "2026-09-08T00:00:00Z",
      "comment": "",
      "hashes": {
        "md5": "...",
        "sha1": "...",
        "sha256": "...",
        "pieces": {"md5": ["..."], "sha1": ["..."], "sha256": ["..."]}
      },
      "sources": [{"type": "openlist-direct", "url": "https://site/d/path"}]
    }
  ]
}
  • channels contain only public driver and optional mount_path; credentials are never serialized.
  • sources are public direct (/d/) or share (/sd/) URLs validated against the configured site URL.

.torrent

Standard BT v1 info/pieces plus a root x-openlist dictionary holding the same optional metadata and a root x-cas dictionary for 189pc rapid-upload info. x-openlist is cross-validated against info (name, piece length, file list, and SHA-1 pieces) before use.

.cas

Strict reference payload. No extension keys. Large files require either a preserved legacy aggregate sliceMd5 or complete 10 MiB MD5 pieces so conversion is lossless.

4. API reference

All endpoints are under POST /api/fs/seed/* (mounted as /fs/seed/*), with legacy /fs/torrent/* routes retained.

Endpoint Purpose
/capabilities Source preflight and destination import planning
/generate Generate one or more seed artifacts
/parse Parse and preview a seed document
/convert Convert between formats with diagnostics
/rapid_upload Native driver reuse only
/offline_download Source → destination transfer (including relayed transfer)
/update Edit metadata and/or recalculate hashes

Common operation envelope: { "seed_data": "<base64>", "file_name": "...", "path": "...", "selected_files": [0], "options": {...} }.

parse returns capabilities: rapid_upload, offline_download, transfer, convert, edit, and recalculate, so the UI only enables actions the backend actually supports.

5. Settings

  • seed_site_url — public site URL used to build share/direct sources (required before embedding sources).
  • seed_default_matrix — default right-click hash matrix.
  • seed_format_policies — global per-format auto-generation switches (all default off).
  • seed_auto_generate_policy — global off/on automatic sidecar policy.
  • seed_single_direct_preview — open single-file seeds directly in preview (default off).
  • Per-storage seed_policyinherit/on/off override that resolves against the global default.

6. Acceptance criteria

  1. Generating a seed for N files reads each file once and computes whole and piece MD5/SHA-1/SHA-256 without loading a whole file into memory.
  2. Selecting torrent forces SHA-1 whole + pieces; selecting cas forces MD5 whole + pieces and a fixed 10 MiB slice size.
  3. .cas output is byte-identical to the reference five-field payload and round-trips without extra keys.
  4. A seed with only MD5 cannot be converted to torrent (missing SHA-1 pieces) and reports that reason.
  5. rapid_upload never silently falls back to a generic upload; it reports unavailable.
  6. A relayed transfer refuses asynchronous offline downloads and requires a synchronous intermediate save.
  7. update validates source URLs against the configured site and rejects cross-host URLs.
  8. recalculate writes the effective piece size back to the seed so piece hashes and piece_size stay consistent.
  9. File operations with follow_seed only touch sidecars of real files, not directories.
  10. All seed parsing enforces byte, file-count, depth, and path-traversal limits.

7. Validation

  • Go: go build ./... passes; go test ./pkg/torrent/... ./server/handles/... ./internal/op/... passes (format compatibility, path safety, parse limits).
  • TypeScript: tsc --noEmit reports zero errors in internal/seed and server/seed.
  • HopeUI: pnpm lint reports zero errors in the seed preview, types, and API files; production build transforms 1209 modules successfully.

8. Security, stability, performance, compliance

  • Security: path-traversal checks, content-write and copy/offline-download permission bits, source URLs restricted to the configured site, SSRF-safe fetch with redirect re-validation, and parse resource limits.
  • Stability: streaming single-pass hashing, bounded memory, synchronous-vs-async relay separation, and rollback of created shares on generation failure.
  • Performance: single-pass multi-hash computation, driver-capability preflight to avoid unnecessary fetches, and 1 GiB synchronous hashing bound.
  • Compliance: no credentials or usernames are serialized into shareable seeds; channels carry only public discovery metadata.

9. Risks and limitations

  • .cas intentionally preserves only the five reference fields; it is lossy by design and cannot carry comments, channels, trackers, or sources.
  • Relayed transfer requires an intermediate storage with synchronous native reuse or PutURL; a fully asynchronous cross-driver relay is out of scope.
  • Recalculate requires the source file to already exist on the server; it does not download from an external source.
  • BT distribution produces a valid .torrent but does not make OpenList a BitTorrent peer; tracker/webseed availability depends on deployment.

Add multi-select context menu action to generate transfer seeds (OSS/torrent/CAS) with a content-matrix wizard: per-algorithm whole/piece hash selection, per-file and overall comments, piece size, trackers, optional share/direct source embedding, and driver-capability preflight showing which files require downloading. Add upload dialog sidecar options (default off) reusing the same matrix. Extend the torrent/seed preview to parse .oss/.torrent/.cas, show hashes, comments, trackers, channels, and drive rapid-upload, offline-download, and format conversion actions gated by backend-reported capabilities. Add optional 'follow transfer seed sidecars' toggle to copy/move/rename/delete dialogs. Add per-storage seed_policy type and global single-file direct-preview setting wired to the backend.
Enable the edit, recalculate and transit-save actions driven by backend capabilities. Add a transit path selector for relayed transfer, per-file source path inputs for hash recalculation, and input validation. Extend seed operation request types and add English labels.
…ss UI

Add an update-channel toggle to seed save operations and apply returned seed_data/share_status after edit. Add CAS direct-access auto-restore on preview and consume the configured default hash matrix in the generate wizard. Add English labels for the new controls.
Replace JSON string editing with user-friendly UI: - Add Seed.tsx: visual hash matrix (MD5/SHA1/SHA256 x whole/pieces), format policies (OSS/Torrent/CAS switches), site URL input, and other options - Add settings_seed.json translations (en/zh-CN) - Register seed menu item in sidemenu_items.tsx with TbSeeding icon - Visual controls replace seed_default_matrix and seed_format_policies JSON editing
@PIKACHUIM
PIKACHUIM force-pushed the feat/advanced-transfer-seeds branch from a9cb887 to acbcbed Compare September 8, 2026 13:43
Card based sections, checkbox hash matrix, switch rows and a single save action. Persisted setting metadata is reused on save so type/group/flag are never overwritten. Drops placeholder i18n keys and adds select option labels for seed settings.
@PIKACHUIM PIKACHUIM added the enhancement New feature or request label Sep 8, 2026
Preview seeds by default, per-file action rows (hash copy, piece modal, preview, remove, recalc, comment copy), merged convert panel, correct destination dir, multi-line comment, and per-file save-method badges via destination capability probe.
Add a hash matrix picker to the bulk recalculate area, defaulting to the hashes already present in the seed. Both bulk and per-file recalculate now pass hash_matrix to the update endpoint.
Merge convert/feasibility into one row, shorten destination with inline save buttons, show driver rapid capability, reuse offline-download tool dialog (BT via magnet), use a source directory instead of manual per-file paths for recalc, and display format full names (OSS/CAS/BT).
Show a queued notice when the backend turns a large seed generation into a background task.
…ns inline

Place Save and Recalculate buttons after the source directory picker instead of a separate row above the matrix, and widen the picker so it flexes to fill available space.
Use the seed file name as the heading, keep the format badge as the format name only, merge size/file-count/created-at into one meta line, and format the timestamp.
Change the destination path picker and convert format select from fixed widths to flex-1 so they expand to fill the remaining space on the row.
…annel

Restore Badge styling for destination driver, supported methods, and rapid availability, and move the update-channel checkbox onto the same row.
Drop the 'Source files are located at' hint and per-file path mapping under the bulk recalculate area.
Add a seed name input so users can override the auto-derived name (single file, common base, or folder).
Only show the legacy CAS warning when the seed carries no per-piece MD5 list.
@PIKACHUIM
PIKACHUIM force-pushed the feat/advanced-transfer-seeds branch from e2c0bad to c1fca2a Compare September 9, 2026 16:41
…d hash requirements

- Display target driver name and supported upload methods
  * Show rapid upload, PUT URL, and offline download capabilities
  * Display required hash algorithms (MD5, SHA1, SHA256, GCID)
  * Show available hashes in the torrent file

- Add intelligent hash matching validation:
  * Check if torrent contains required hashes for target driver
  * Display clear unavailability reasons with tooltips
  * Color-coded badges for quick status recognition

- Improve user experience with visual feedback:
  * Green badge: rapid upload available with matching hashes
  * Yellow badge: rapid upload unavailable
  * Blue badge: informational display
  * Purple badge: required hash algorithms

- Add comprehensive i18n support:
  * Complete Chinese translations for all new features
  * English translations for international users
  * Clear error messages and hints

This enhancement helps users understand why rapid upload may fail and what hashes are needed, significantly improving the torrent transfer workflow.
…ization to search for entry.ts modules\n- Support both index.ts and entry.ts naming conventions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant