8d1d641f97
2 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
644ed712e0 |
fix(rotation): persist the round-robin cursor so drip-fed uploads keep rotating
v3.3.74 created a fresh account picker inside every buildUploadTasks /
buildUploadTasksFromJobs call, so its in-memory rotation index reset to 0
on each call. That is correct for a one-shot batch (drag-drop N files at
once distributes fine), but it silently no-ops in exactly the pattern the
byse 80-uploads/30-days quota cares about: the folder monitor feeds new
files into a *running* batch one detection at a time via add-jobs-to-batch
(renderer -> add-jobs-to-batch IPC), and per-detection autoStart likewise
fires start-upload per file. Each of those calls rebuilt the picker from
index 0, so account 1 won every single time and the secondary accounts
never received anything.
The rotation cursor now lives outside the picker and survives across calls
and across app restarts (the quota spans a rolling 30-day window, so a
session-only counter would still starve secondaries for users who restart
between small uploads):
- account-rotation.js: createAccountPicker() accepts a seed { indices } map,
resumes the per-hoster cursor from it, and exposes indices() (the advanced
cursors) + dirty() (whether any rotation actually happened this call). The
cursor is a monotonic counter taken mod the current enabled-account count,
so it keeps wrapping correctly even if an account is later enabled/disabled.
- config-store.js: new top-level rotationCursors map (added to DEFAULTS, read
back in load() which otherwise reconstructs the result and would drop
unknown keys) plus a saveRotationCursors() method. The existing
read-modify-write save() preserves it across unrelated settings/credential
saves; secret-store never touches it.
- main.js: a module-level _rotationCursors is the authoritative source of
truth (seeded once from disk on first use, updated synchronously per batch),
with config as restart-survival backing. makeAccountPicker() seeds the
picker from it; persistRotation() folds the advance back and flushes to
config only when dirty. Authoritative in-memory state also closes the
disk-read race two rapid batches would otherwise hit. Both task builders
now receive the picker instead of constructing their own.
Composition with failover is unchanged and verified: the picker only chooses
each file's *initial* account and is never called on the failover path. The
pre-job-swap reroutes a task only when that task's own account is in
_failedAccounts, so a dead account's jobs reroute while healthy accounts keep
their rotation share. No double-advance of the cursor.
Tests: account-rotation gains seeded-resume, drip-feed-across-pickers (the
regression), dirty()-semantics, carry-forward, and count-shrink-wrap cases;
config-store gains rotationCursors default, save round-trip, no-clobber, and
credentials-undisturbed cases. Full suite 303/303.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
||
|
|
3204629fef |
feat(rotation): opt-in per-hoster account rotation to keep all accounts active
byse.sx requires each account to upload >=80 videos in the last 30 days (measured across a rolling 3-month window) or it goes dormant. With a single primary account doing all the work, the other configured accounts decay and eventually get suspended. This adds an opt-in "Accounts rotieren" toggle per hoster that round-robins files across every enabled account that has credentials: file 1 -> account 1, file 2 -> account 2, file 3 -> account 3, then wraps. Off by default, so existing single-account behavior is unchanged. Mechanics: - New lib/account-rotation.js: createAccountPicker() returns a stateful pick(hoster) closure holding a per-hoster round-robin index. It only rotates when rotateAccounts === true AND more than one usable account exists; otherwise it returns the first enabled account (the old primary). enabledAccountsFor() filters disabled + credential-less accounts while preserving configured order, so a disabled account is simply skipped in the cycle rather than leaving a gap. - main.js: both buildUploadTasks() and buildUploadTasksFromJobs() now build one picker per call and use pick(hoster) instead of getPrimaryAccount(), which is now removed (dead code). A fresh picker per batch means each upload session starts the cycle at account 1, matching "die erste Datei auf Account eins". - config-store.js: rotateAccounts: false added to HOSTER_SETTINGS_DEFAULTS. - renderer/app.js: "Accounts rotieren" checkbox in the per-hoster upload settings (Accounts tab). Persisted by the existing generic checkbox path in saveHosterSettingsFromDom(). Composes with failover: rotation only chooses the *initial* account per file. On a hard account failure the existing failover (_failedAccounts + pre-job account swap) reroutes just that account's jobs; the healthy accounts keep their rotation share. Single enabled account (or rotation off) = no behavior change. Tests: tests/account-rotation.test.js (10 cases) covers off=primary, on=round-robin+wrap, single-account no-op, skip disabled, skip no-creds, null when none usable, per-hoster index independence, byse-only rotation, 100-file 50/50 split, and the enabledAccountsFor filter. Full suite 294/294. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |