MCPcopy Create free account
hub / github.com/mempool/mempool / getLocalHash

Function getLocalHash

frontend/sync-assets.js:105–121  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

103
104// Utility: Get local file hash (Git blob format)
105const getLocalHash = (filePath) => {
106 const stats = fsSync.statSync(filePath);
107 const buffer = fsSync.readFileSync(filePath);
108 const bufferWithHeader = Buffer.concat([
109 Buffer.from('blob '),
110 Buffer.from(`${stats.size}`),
111 Buffer.from('\0'),
112 buffer
113 ]);
114 const hash = crypto.createHash('sha1').update(bufferWithHeader).digest('hex');
115
116 if (config.verbose) {
117 console.log(`${LOG_TAG} \t\tgetLocalHash ${filePath} ${hash}`);
118 }
119
120 return hash;
121};
122
123// Utility: Create GitHub API options
124const createGitHubOptions = (repoPath) => {

Callers 1

processFileItemFunction · 0.85

Calls 2

digestMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected