MCPcopy Create free account
hub / github.com/anus-dev/ANUS / moveBinary

Function moveBinary

scripts/telemetry_utils.js:115–139  ·  view source on GitHub ↗
(source, destination)

Source from the content-addressed store, hash-verified

113}
114
115export function moveBinary(source, destination) {
116 try {
117 fs.renameSync(source, destination);
118 } catch (error) {
119 if (error.code !== 'EXDEV') {
120 throw error;
121 }
122 // Handle a cross-device error: copy-to-temp-then-rename.
123 const destDir = path.dirname(destination);
124 const destFile = path.basename(destination);
125 const tempDest = path.join(destDir, `${destFile}.tmp`);
126
127 try {
128 fs.copyFileSync(source, tempDest);
129 fs.renameSync(tempDest, destination);
130 } catch (moveError) {
131 // If copy or rename fails, clean up the intermediate temp file.
132 if (fs.existsSync(tempDest)) {
133 fs.unlinkSync(tempDest);
134 }
135 throw moveError;
136 }
137 fs.unlinkSync(source);
138 }
139}
140
141export function waitForPort(port, timeout = 10000) {
142 return new Promise((resolve, reject) => {

Callers 1

ensureBinaryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected