Skip to content

Commit 1fe2c2d

Browse files
committed
refactor: extract storage hash helper
1 parent 1df5893 commit 1fe2c2d

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

lib/storage.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { AsyncLocalStorage } from "node:async_hooks";
2-
import { createHash } from "node:crypto";
32
import { existsSync, promises as fs } from "node:fs";
43
import { basename, dirname, join } from "node:path";
54
import { ACCOUNT_LIMITS } from "./constants.js";
@@ -23,6 +22,7 @@ import {
2322
import { isCacheLikeBackupArtifactName } from "./storage/cache-artifacts.js";
2423
import { formatStorageErrorHint } from "./storage/error-hints.js";
2524
import { loadFlaggedAccountsFromFile } from "./storage/flagged-storage-file.js";
25+
import { computeSha256 } from "./storage/hash.js";
2626
import {
2727
collectNamedBackups,
2828
type NamedBackupSummary,
@@ -472,10 +472,6 @@ async function cleanupStaleRotatingBackupArtifacts(
472472
}
473473
}
474474

475-
function computeSha256(value: string): string {
476-
return createHash("sha256").update(value).digest("hex");
477-
}
478-
479475
function createEmptyStorageWithMetadata(
480476
restoreEligible: boolean,
481477
restoreReason: RestoreReason,

lib/storage/hash.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createHash } from "node:crypto";
2+
3+
export function computeSha256(value: string): string {
4+
return createHash("sha256").update(value).digest("hex");
5+
}

0 commit comments

Comments
 (0)