MCPcopy Create free account
hub / github.com/Noumena-Network/code / writeFileSync_DEPRECATED

Function writeFileSync_DEPRECATED

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

Source from the content-addressed store, hash-verified

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

Callers 15

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

Calls

no outgoing calls

Tested by

no test coverage detected