Skip to content

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

@jiexinkai-newbee

Description

@jiexinkai-newbee

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);
    }
  }

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions