Skip to content

feat: add folder#703

Merged
hacdias merged 8 commits intorevampfrom
feat/revamp/upload-options
Jul 4, 2018
Merged

feat: add folder#703
hacdias merged 8 commits intorevampfrom
feat/revamp/upload-options

Conversation

@hacdias
Copy link
Copy Markdown
Member

@hacdias hacdias commented Jul 3, 2018

image

Copy link
Copy Markdown
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting! Some quick feedback:

  • I feel we should fix files.write before this is merged to avoid issues described in #676
  • In files listing, icons should be clickable and have pointer cursor (right now only file name is)
  • Switch to streams is optional (If API is backed by js-ipfs-api it buffers entire thing anyway, I think).

Comment thread src/bundles/files.js
promises.push(readAsBuffer(file))
}
for (const file of files) {
promises.push(readAsBuffer(file))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a separate PR, but we may want to replace readAsBuffer with pull stream to improve performance when adding big files:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please. Is ok for separate PR, but we've gotta make this the best file uploader we can.

Comment thread src/bundles/files.js Outdated
return Promise.all(files.map((file) => {
await Promise.all(files.map(file => {
const target = join(root, file.name)
return getIpfs().files.write(target, file.content, { create: true })
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid files.write, as it will produce different CID than add.
See details and workaround in: #676

@hacdias hacdias changed the title [WIP] feat: add folders and add by path [WIP] feat: add folder Jul 3, 2018
@hacdias hacdias mentioned this pull request Jul 3, 2018
18 tasks
@hacdias hacdias changed the title [WIP] feat: add folder feat: add folder Jul 3, 2018
@hacdias hacdias force-pushed the feat/revamp/upload-options branch from 7579896 to fe048c4 Compare July 3, 2018 18:15
@hacdias
Copy link
Copy Markdown
Member Author

hacdias commented Jul 3, 2018

@lidel I just made the files.write change and gave the dropdown some styling. I'll add each feature in a different PR to keep everything small. Could you see if the code's looking good?

@hacdias hacdias self-assigned this Jul 3, 2018
@hacdias hacdias added the revamp label Jul 3, 2018
Copy link
Copy Markdown
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • After upload is finished menu with "Add" actions should close
  • Missing some kind of visual feedback and Adding bigger files. Perhaps putting % on label while upload is happening would do for now? (similar to how we handled Download for now)

Comment thread src/bundles/files.js Outdated
const target = join(root, file.name)
return getIpfs().files.write(target, file.content, { create: true })
await Promise.all(files.map(async file => {
const res = await getIpfs().add([file.content])
Copy link
Copy Markdown
Member

@lidel lidel Jul 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should disable pinning when adding for MFS.
As long as files are in MFS, they won't be GC'd.
If we dont pass {pin: false} to add then removing file from MFS won't remove it from node during next gc, and this disk-space leakage may confuse less technical users.
Is that a bug or feature ?
@olizilla any thoughts on this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding that option then.

About the progress of uploading: don't worry. Won't be doing in this PR but it is on Invision how it is supposed to be.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @lidel

@hacdias
Copy link
Copy Markdown
Member Author

hacdias commented Jul 4, 2018

Done @lidel

Comment thread src/lib/path.js Outdated
return `${a}/${b}`
}

export function dirname (path) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just use node core path stuff for this kind of thing, https://nodejs.org/api/path.html#path_path_dirname_path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of note this file was intended to be a lib for ipfs/ipld path helpers, rather than any sort of path.

Copy link
Copy Markdown
Member

@olizilla olizilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is good work. Please use node path module for dirname and join stuff.

@hacdias
Copy link
Copy Markdown
Member Author

hacdias commented Jul 4, 2018

Done @olizilla

@olizilla
Copy link
Copy Markdown
Member

olizilla commented Jul 4, 2018

if nothing else is using our join impl, can you remove it pls. If there is usages, pls update them.

@hacdias
Copy link
Copy Markdown
Member Author

hacdias commented Jul 4, 2018

Done @olizilla. Since I've already solved the issues you and @lidel mentioned, I'm going to merge this so I can continue to the next feature 😄

@hacdias hacdias merged commit 9f6a147 into revamp Jul 4, 2018
@hacdias hacdias deleted the feat/revamp/upload-options branch July 4, 2018 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants