MCPcopy
hub / github.com/jvilk/BrowserFS / _syncSync

Method _syncSync

src/generic/key_value_filesystem.ts:403–424  ·  view source on GitHub ↗
(p: string, data: Buffer, stats: Stats)

Source from the content-addressed store, hash-verified

401 }
402
403 public _syncSync(p: string, data: Buffer, stats: Stats): void {
404 // @todo Ensure mtime updates properly, and use that to determine if a data
405 // update is required.
406 const tx = this.store.beginTransaction('readwrite'),
407 // We use the _findInode helper because we actually need the INode id.
408 fileInodeId = this._findINode(tx, path.dirname(p), path.basename(p)),
409 fileInode = this.getINode(tx, p, fileInodeId),
410 inodeChanged = fileInode.update(stats);
411
412 try {
413 // Sync data.
414 tx.put(fileInode.id, data, true);
415 // Sync metadata.
416 if (inodeChanged) {
417 tx.put(fileInodeId, fileInode.toBuffer(), true);
418 }
419 } catch (e) {
420 tx.abort();
421 throw e;
422 }
423 tx.commit();
424 }
425
426 /**
427 * Checks if the root directory exists. Creates it if it doesn't.

Callers 1

syncSyncMethod · 0.45

Calls 8

_findINodeMethod · 0.95
getINodeMethod · 0.95
updateMethod · 0.80
beginTransactionMethod · 0.65
putMethod · 0.65
abortMethod · 0.65
commitMethod · 0.65
toBufferMethod · 0.45

Tested by

no test coverage detected