فهرست منبع

Don't recurse directories while displaying tree during info command (#656)

The `tauri info` command displays the directories in the application dir. It only
displays 1 directory deep, but the function finding them recurses all subdirectories.
Limiting finding directories to 1 layer deep significantly reduces time to display
the folder from 9900ms to 4ms on my machine.
chip 5 سال پیش
والد
کامیت
69ac1c5228
1فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 6 4
      cli/tauri.js/src/api/info.ts

+ 6 - 4
cli/tauri.js/src/api/info.ts

@@ -18,7 +18,7 @@ interface DirInfo {
 }
 
 /* eslint-disable security/detect-non-literal-fs-filename */
-function dirTree(filename: string): DirInfo {
+function dirTree(filename: string, recurse = true): DirInfo {
   const stats = fs.lstatSync(filename)
   const info: DirInfo = {
     path: filename,
@@ -27,9 +27,11 @@ function dirTree(filename: string): DirInfo {
 
   if (stats.isDirectory()) {
     info.type = 'folder'
-    info.children = fs.readdirSync(filename).map(function(child: string) {
-      return dirTree(filename + '/' + child)
-    })
+    if (recurse) {
+      info.children = fs.readdirSync(filename).map(function(child: string) {
+        return dirTree(filename + '/' + child, false)
+      })
+    }
   } else {
     info.type = 'file'
   }