protect stat call

This commit is contained in:
tdurieux
2021-05-03 14:52:42 +02:00
parent be679286af
commit 7d15a26e51
+13 -9
View File
@@ -20,15 +20,19 @@ async function walk(dir, root) {
const output = { child: {} }; const output = { child: {} };
for (let file of files) { for (let file of files) {
let filePath = path.join(dir, file); let filePath = path.join(dir, file);
const stats = await fs.stat(filePath); try {
if (file[0] == "$") { const stats = await fs.stat(filePath);
file = "\\" + file; if (file[0] == "$") {
} file = "\\" + file;
if (stats.isDirectory()) { }
output.child[file] = await walk(filePath, root); if (stats.isDirectory()) {
output.child[file].sha = stats.ino; output.child[file] = await walk(filePath, root);
} else if (stats.isFile()) { output.child[file].sha = stats.ino;
output.child[file] = { size: stats.size, sha: stats.ino }; } else if (stats.isFile()) {
output.child[file] = { size: stats.size, sha: stats.ino };
}
} catch (error) {
console.error(error);
} }
} }
return output; return output;