Skip to content

ftpExplorer in tree-view-sample can only retrieve top level files #1155

@bogdanm

Description

@bogdanm

Extension sample

tree-view-sample

VS Code version

1.98.1 (Universal)

What went wrong?

In the tree-view-sample, the FTP explorer can retrieve files only from the top level directory (/) of an FTP server. Attempting to retrieve files from a subdirectory failes with an error.

Steps to reproduce:

  1. Clone the repository.
  2. Open the tree-view-sample subdirectory in Visual Studio Code.
  3. Since the code uses an FTP server that doesn't work anymore, edit ftpExplorer.ts and change the server. For example:
diff --git a/tree-view-sample/src/ftpExplorer.ts b/tree-view-sample/src/ftpExplorer.ts
index 4bb05ccd..c0218188 100644
--- a/tree-view-sample/src/ftpExplorer.ts
+++ b/tree-view-sample/src/ftpExplorer.ts
@@ -148,7 +148,7 @@ export class FtpExplorer {

        constructor(context: vscode.ExtensionContext) {
                /* Please note that login information is hardcoded only for this example purpose and recommended not to do it in general. */
-               const ftpModel = new FtpModel('mirror.switch.ch', 'anonymous', '[email protected]');
+               const ftpModel = new FtpModel('test.rebex.net', 'anonymous', '[email protected]');
                const treeDataProvider = new FtpTreeDataProvider(ftpModel);
                context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider('ftp', treeDataProvider));
  1. Start to debug the extension.
  2. Go to "FTP explorer" and click on the top level readme.txt file. The content on the file should be displayed.
  3. Close the readme.txt file tab in the editor.
  4. In the "FTP explorer" pane, navigate to /pub/example and click on the readme.txt from this directory.

Expected behaviour: the file is retrieved and displayed just like the top level readme.txt.

Actual behaviour: no file is displayed and the parent VSCode window displays this error in the debug console:

rejected promise not handled within 1 second: CodeExpectedError: cannot open file:///pub/example/readme.txt. Detail: Unable to read file '/pub/example/readme.txt' (Error: Unable to resolve nonexistent file '/pub/example/readme.txt')
extensionHostProcess.js:178
stack trace: CodeExpectedError: cannot open file:///pub/example/readme.txt. Detail: Unable to read file '/pub/example/readme.txt' (Error: Unable to resolve nonexistent file '/pub/example/readme.txt')
    at i7e.$tryOpenDocument (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1246:8627)```

Downloading /pub/example/readme.txt with an FTP client works.
This issue was observed on all tested FTP servers.

Repository HEAD: 46f526c
npm: 11.1.0
node: 22.14.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions