Skip to content

refactor: unify doStuff/undoStuff via FILE_OPS config table#58

Merged
jacaudi merged 4 commits into
mainfrom
refactor/file-ops-unification
Apr 12, 2026
Merged

refactor: unify doStuff/undoStuff via FILE_OPS config table#58
jacaudi merged 4 commits into
mainfrom
refactor/file-ops-unification

Conversation

@jacaudi
Copy link
Copy Markdown
Owner

@jacaudi jacaudi commented Apr 12, 2026

Summary

  • Collapse the two near-identical doStuff (encrypt, 34 lines) and undoStuff (decrypt, 34 lines) functions in src/js/ui/file-ops.js into one processFileBatch(direction) driver.
  • Introduce a FILE_OPS config table with enc and dec entries capturing the per-direction axes (worker call, buffer transform, filename transform, error message, status flag).
  • Preserve doStuff and undoStuff as 1-line wrappers so file-import.js callers keep working unchanged.
  • Add regression tests (public entry points still exist as top-level functions) and source-level tests (FILE_OPS shape + processFileBatch + filename transform round-trip).

Test plan

  • docker run --rm -v $(pwd):/work -w /work node:22-alpine sh -c "node scripts/build.js && node --test app/tests/test-*.js" — 174/174 passing (166 baseline + 8 new)
  • doStuff and undoStuff still declared as top-level functions in built app/index.html
  • Filename round-trip: decSuffix(encSuffix(name)) === name for foo.txt, report.pdf, no-extension
  • Manual round-trip in browser (encrypt → decrypt → verify contents byte-identical to original)

Out of scope

handleSharedFile (share path) is explicitly kept out of this refactor per the design — it has a different flow.

🤖 Generated with Claude Code

@jacaudi jacaudi merged commit dfc9732 into main Apr 12, 2026
13 checks passed
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