shell: rework code to use shell.spawn
spawn gives out streams and we have more control over the stdout/stderr buffers. otherwise, we have to provide a max buffer capture size to exec
This commit is contained in:
@@ -125,13 +125,13 @@ async function saveFsMetadata(dataLayout, metadataFile) {
|
||||
|
||||
// we assume small number of files. spawnSync will raise a ENOBUFS error after maxBuffer
|
||||
for (const lp of dataLayout.localPaths()) {
|
||||
const emptyDirs = await shell.exec(`find ${lp} -type d -empty`, { maxBuffer: 1024 * 1024 * 80 });
|
||||
const emptyDirs = await shell.spawn('find', [lp, '-type', 'd', '-empty'], { encoding: 'utf8', maxBuffer: 1024 * 1024 * 80 });
|
||||
if (emptyDirs.length) metadata.emptyDirs = metadata.emptyDirs.concat(emptyDirs.trim().split('\n').map((ed) => dataLayout.toRemotePath(ed)));
|
||||
|
||||
const execFiles = await shell.exec(`find ${lp} -type f -executable`, { maxBuffer: 1024 * 1024 * 80 });
|
||||
const execFiles = await shell.spawn('find', [lp, '-type', 'f', '-executable'], { encoding: 'utf8', maxBuffer: 1024 * 1024 * 80 });
|
||||
if (execFiles.length) metadata.execFiles = metadata.execFiles.concat(execFiles.trim().split('\n').map((ef) => dataLayout.toRemotePath(ef)));
|
||||
|
||||
const symlinkFiles = await shell.exec(`find ${lp} -type l`, { maxBuffer: 1024 * 1024 * 30 });
|
||||
const symlinkFiles = await shell.spawn('find', [lp, '-type', 'l'], { encoding: 'utf8', maxBuffer: 1024 * 1024 * 30 });
|
||||
if (symlinkFiles.length) metadata.symlinks = metadata.symlinks.concat(symlinkFiles.trim().split('\n').map((sl) => {
|
||||
const target = safe.fs.readlinkSync(sl);
|
||||
return { path: dataLayout.toRemotePath(sl), target };
|
||||
|
||||
Reference in New Issue
Block a user