MCPcopy
hub / github.com/codeaashu/claude-code / tryReadFileForSync

Function tryReadFileForSync

src/services/settingsSync/index.ts:398–416  ·  view source on GitHub ↗

* Try to read a file for sync, with size limit and error handling. * Returns null if file doesn't exist, is empty, or exceeds size limit.

(filePath: string)

Source from the content-addressed store, hash-verified

396 * Returns null if file doesn't exist, is empty, or exceeds size limit.
397 */
398async function tryReadFileForSync(filePath: string): Promise<string | null> {
399 try {
400 const stats = await stat(filePath)
401 if (stats.size > MAX_FILE_SIZE_BYTES) {
402 logForDiagnosticsNoPII('info', 'settings_sync_file_too_large')
403 return null
404 }
405
406 const content = await readFile(filePath, 'utf8')
407 // Check for empty/whitespace-only without allocating a trimmed copy
408 if (!content || /^\s*$/.test(content)) {
409 return null
410 }
411
412 return content
413 } catch {
414 return null
415 }
416}
417
418async function buildEntriesFromLocalFiles(
419 projectId: string | null,

Callers 1

Calls 3

statFunction · 0.85
logForDiagnosticsNoPIIFunction · 0.85
readFileFunction · 0.85

Tested by

no test coverage detected