Repository navigation
chore: cleanup second precision and test setup for file backend - #1429
Conversation
Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
Coverage Report for CI Build 35728327056Coverage decreased (-0.005%) to 83.392%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
There was a problem hiding this comment.
Looks good — this is a mechanical refactor with no behavior change.
What was reviewed:
- The new
toSecondshelper drops the old explicit invalid-date guard; confirmed this is safe because<=/>comparisons againstNaNalways evaluate tofalsein both the read-path and copy-precondition checks, reproducing the old "undefined skip" behavior exactly. The existing tests (ignores an invalid if-modified-since date,ignores invalid precondition dates) still exercise this and pass. - The
file.test.tsrefactor introducinguseFileBackend(): verified it preserves setup/teardown semantics — onlySTORAGE_FILE_BACKEND_PATHis stubbed, which is fine since config resolution treatsFILE_STORAGE_BACKEND_PATHas a fallback only — and no test cases were dropped, just de-duplicated.
Extended reasoning...
The diff touches only src/storage/backend/file.ts (extracting a shared toSeconds helper for HTTP-date precondition comparisons) and its test file (a mechanical setup/teardown de-duplication via a useFileBackend() helper, no test cases added or removed). No security-sensitive surface beyond precondition/date-comparison logic, which I traced by hand: removing the old undefined-guard in toSeconds is behavior-preserving because NaN comparisons resolve to false either way, and this is backed by pre-existing tests covering invalid If-Modified-Since and invalid copy-precondition dates. The test refactor's env-var handling (only stubbing STORAGE_FILE_BACKEND_PATH) is also safe since it takes precedence over the FILE_STORAGE_BACKEND_PATH fallback in config.ts. No bug hunter findings, no open third-party objections, and the change is small, self-contained, and verified equivalent.
What kind of change does this PR introduce?
refactor
What is the current behavior?
Second truncation for HTTP date is duplicated.
Setup is duplicated.
What is the new behavior?
Extract helpers.
Additional context
Related to #1407, #1422