Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

读取文件夹树的时候,会把文件夹识别成文件 #56

Open
jiexinkai-newbee opened this issue May 11, 2023 · 1 comment
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@jiexinkai-newbee
Copy link

hi,我在集成ide-startup-lite的时候,发现有些时候,读取一些空文件夹的时候,会把这个文件夹识别成文件,这个问题,我已经发现并在我本地进行了解决:
读取文件夹树的时候,会把文件夹读取成文件:
web-lite/file-provider/browser-fs-provider.ts

    // waiting for HttpFileService ready
    await this.httpFileService.whenReady;
    const childNodes = await this.httpFileService.readDir(uri.codeUri);
    const ensureNodes: Promise<FileStat>[] = [];
    for (const node of childNodes) {
      if (node.children.length) {
        ensureNodes.push(this.createDirectory(URI.file(new Path(this.options.rootFolder).join(`${node.path}`).toString()).codeUri));
      } else {
        ensureNodes.push(this.writeFile(URI.file(new Path(this.options.rootFolder).join(`${node.path}`).toString()).codeUri, BinaryBuffer.fromString('').buffer, {create: true, isInit: true, overwrite: false}) as Promise<FileStat>);
      }
    }
    try {
      await Promise.all(ensureNodes);
    } catch (err) {
      // console.error('node fetch failed ', err);
    }
  }

这里通过判断节点的子节点的数量来达到识别是否是文件夹的处理,会导致一些空文件夹识别成文件

@erha19
Copy link
Member

erha19 commented May 12, 2023

@jiexinkai-newbee 感谢反馈,这里使用 node.children.length 判断确实是不严谨的,可以考虑采用 node.content.typenode.content.mode 去判断会更加严谨,方便的话可以提交个 PR 来修复一下 ~

@erha19 erha19 added bug Something isn't working good first issue Good for newcomers labels May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants