MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / writeFileSync_DEPRECATED

Function writeFileSync_DEPRECATED

source code/utils/slowOperations.ts:250–288  ·  view source on GitHub ↗
(
  filePath: string,
  data: string | NodeJS.ArrayBufferView,
  options?: WriteFileOptionsWithFlush,
)

Source from the content-addressed store, hash-verified

248 * Sync file writes block the event loop and cause performance issues.
249 */
250export function writeFileSync_DEPRECATED(
251 filePath: string,
252 data: string | NodeJS.ArrayBufferView,
253 options?: WriteFileOptionsWithFlush,
254): void {
255 using _ = slowLogging`fs.writeFileSync(${filePath}, ${data})`
256
257 // Check if flush is requested (for object-style options)
258 const needsFlush =
259 options !== null &&
260 typeof options === 'object' &&
261 'flush' in options &&
262 options.flush === true
263
264 if (needsFlush) {
265 // Manual flush: open file, write, fsync, close
266 const encoding =
267 typeof options === 'object' && 'encoding' in options
268 ? options.encoding
269 : undefined
270 const mode =
271 typeof options === 'object' && 'mode' in options
272 ? options.mode
273 : undefined
274 let fd: number | undefined
275 try {
276 fd = openSync(filePath, 'w', mode)
277 fsWriteFileSync(fd, data, { encoding: encoding ?? undefined })
278 fsyncSync(fd)
279 } finally {
280 if (fd !== undefined) {
281 closeSync(fd)
282 }
283 }
284 } else {
285 // No flush needed, use standard writeFileSync
286 fsWriteFileSync(filePath, data, options as WriteFileOptions)
287 }
288}

Callers 14

loadSettingsFromFlagFunction · 0.85
showInvalidConfigDialogFunction · 0.85
handleFilenameSubmitFunction · 0.85
editPromptInEditorFunction · 0.85
profileReportFunction · 0.85
writeLockFileFunction · 0.85
updateFunction · 0.85
saveInstalledPluginsV2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected