MCPcopy Create free account
hub / github.com/cloudflare/computer / rename

Function rename

packages/computerd/src/fuse/driver.ts:776–810  ·  view source on GitHub ↗
(source, destination, cb)

Source from the content-addressed store, hash-verified

774 },
775
776 rename(source, destination, cb) {
777 try {
778 if (isPendingCreate(source)) {
779 // Source hasn't been persisted yet, so there's nothing for
780 // the VFS to move. POSIX rename(2) overwrites a regular file
781 // at the destination; honour that here by unlinking any
782 // pre-existing destination inode and dropping any pending
783 // entry that was staged at it. The next flush of the
784 // remapped buffer will create the dest inode fresh.
785 const destPending = isPendingCreate(destination);
786 if (!destPending && vfs.existsSync(toVfs(destination))) {
787 vfs.unlinkSync(toVfs(destination));
788 }
789 if (destPending) {
790 files.delete(destination);
791 }
792 meta.delete(destination);
793 } else {
794 vfs.renameSync(toVfs(source), toVfs(destination));
795 }
796 const m = meta.get(source);
797 if (m !== undefined) {
798 meta.delete(source);
799 meta.set(destination, m);
800 }
801 const entry = files.get(source);
802 if (entry !== undefined) {
803 files.delete(source);
804 files.set(destination, entry);
805 }
806 cb(0);
807 } catch (error) {
808 cb(toErrno(error));
809 }
810 },
811
812 access(path, mode, cb) {
813 try {

Callers

nothing calls this directly

Calls 9

isPendingCreateFunction · 0.85
toVfsFunction · 0.85
toErrnoFunction · 0.85
existsSyncMethod · 0.80
unlinkSyncMethod · 0.80
renameSyncMethod · 0.80
deleteMethod · 0.65
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected