Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions src/service/plugins/sftp.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,34 @@ const SFTPPlugin = GObject.registerClass({

async _listDirectories(mount) {
const file = mount.get_root();
const directories = {};

const iter = await file.enumerate_children_async(
Gio.FILE_ATTRIBUTE_STANDARD_NAME,
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
GLib.PRIORITY_DEFAULT,
this.cancellable);
try {
const iter = await file.enumerate_children_async(
Gio.FILE_ATTRIBUTE_STANDARD_NAME,
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
GLib.PRIORITY_DEFAULT,
this.cancellable);

const infos = await iter.next_files_async(MAX_MOUNT_DIRS,
GLib.PRIORITY_DEFAULT, this.cancellable);
iter.close_async(GLib.PRIORITY_DEFAULT, null, null);
const infos = await iter.next_files_async(MAX_MOUNT_DIRS,
GLib.PRIORITY_DEFAULT, this.cancellable);
iter.close_async(GLib.PRIORITY_DEFAULT, null, null);

const directories = {};
for (const info of infos) {
const name = info.get_name();
directories[name] = `${file.get_uri()}${name}/`;
}
} catch (e) {
debug(e, this.device.name);

for (const info of infos) {
const name = info.get_name();
directories[name] = `${file.get_uri()}${name}/`;
// If no directories were found, fall back to using 'multiPaths'
if (this._mount_body.hasOwnProperty('multiPaths')) {
for (let i = 0; i < this._mount_body.multiPaths.length; i++) {
const name = this._mount_body.pathNames[i];
const path = this._mount_body.multiPaths[i];
directories[name] = `${file.get_uri()}${path}/`;
}
}
}

return directories;
Expand Down Expand Up @@ -206,6 +218,7 @@ const SFTPPlugin = GObject.registerClass({
return;

this._mounting = true;
this._mount_body = packet.body;

// Ensure the private key is in the keyring
await this._addPrivateKey();
Expand Down
Loading