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

fix: open directory from webui #1472

Merged
merged 1 commit into from
Apr 29, 2020
Merged
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
54 changes: 26 additions & 28 deletions src/webui/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,33 @@ window.ipfsDesktop = {

version: VERSION,

selectDirectory: () => {
return new Promise(resolve => {
remote.dialog.showOpenDialog(remote.getCurrentWindow(), {
title: 'Select a directory',
properties: [
'openDirectory',
'createDirectory'
]
}, async (res) => {
if (!res || res.length === 0) {
return resolve()
}

const files = []

const prefix = path.dirname(res[0])

for (const path of await readdir(res[0])) {
const size = (await fs.stat(path)).size
files.push({
path: path.substring(prefix.length, path.length),
content: toPull.source(fs.createReadStream(path)),
size: size
})
}

resolve(files)
})
selectDirectory: async () => {
const response = await remote.dialog.showOpenDialog(remote.getCurrentWindow(), {
title: 'Select a directory',
properties: [
'openDirectory',
'createDirectory'
]
})

if (!response || response.canceled) {
return
}

const files = []
const filesToRead = response.filePaths[0]
const prefix = path.dirname(filesToRead)

for (const path of await readdir(filesToRead)) {
const size = (await fs.stat(path)).size
files.push({
path: path.substring(prefix.length, path.length),
content: toPull.source(fs.createReadStream(path)),
size: size
})
}

return files
},

removeConsent: (consent) => {
Expand Down