ipfs/ipfs-webui

option to enable automatically pin file when upload

trim21 opened this issue · 13 comments

trim21 commented

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

this would behavior like ipfs cli ipfs add --pin=true ...

current file uploaded by webui doesn't get pinned, behavoir like ipfs add --pin=false ..., so I need to pin them manually.

I hope we can add a option/flag to make uploaded file automatily pinned, just like ipfs add --pin=true ...

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

Thanks for submitting this issue @trim21, is the ask here to have a global option to always "pin" files?

Maybe @lidel or @hacdias can elaborate more on this, there seems to be some discussion in this issue: ipfs/ipfs-gui#10 (comment) which seems to indicate that files imported are already implicitly pinned (maybe I'm wrong), I think if that's true, the "pin" feature should just be removed.

trim21 commented

is the ask here to have a global option to always "pin" files?

yes, option to pin new files when they are uploaded

I think if that's true, the "pin" feature should just be removed.

Then how do users make sure their files won't get GC-ed...

@trim21, just wondering if you have been facing loss of data? A simple way to achieve this could be adding a root folder which has the pin enabled, then adding everything you want pinned in that root folder.

Will that work?

trim21 commented

just wondering if you have been facing loss of data?

no, I always manully pin them.

A simple way to achieve this could be adding a root folder which has the pin enabled, then adding everything you want pinned in that root folder.

This look a good solution.

So are all files in that folder will get pinned, and when I remove them, they will get GC-ed?

@trim21 that is correct, if that's not the behaviour you experience. I'd like you to share your findings, that'll be a bug in the current implementation and that can be prioritized.

trim21 commented

Thanks, this's the behaviour I want

Closing this issue as fixed, please feel free to reopen or submit a new issue if you face this again!

trim21 commented

After some time, I find this is not a valid solution...

If you pin a directory with 2 files, and you upload a new file, the cid of directory will changed, the directory and newly uploaded file are not automatically pin-ed

trim21 commented

For example, I have a directory called images, it now have 2 files, 1.jpg and 2.jpg

and I can pin directory images, I'm actually pinning cid1, for example QmWVi3AM6mzfCD8gdVLfyuM6QJEzEbq1b34dkSwRsMuE2K
image

But when I upload a new image, the content of directory changed, therefore the cid of directory also changed, and the new directory(which has the same name) is not pinned anymore, which mean I have to pin this directory again.

image

And when I pin it, I'm actually pinning cid2, for example Qmf4KCLrm2SCzCFkxFUt6c5QzNAW63W2xf6ghEj432XSrg

(funny enough, when I remove the newly added file, I can see the directory is pinned again)

So the suggestion doesn't fix this issue, I still have to pin the file I uploaded.

trim21 commented

@whizzzkid can you re-open this issue?

@trim21 ok yes I see what you mean, apologies, reopening this issue.

I ran across this situation for my use-case too. In general a node keeps the items in the "files" area from being garbage-collected, but for different configurations of "Reprovider > Strategy", there is a setting for "pinned" but not for "in files", so having content be not just "in the local files directory" but actively pinned is important. Having the "pin" action in the "files" area not adjust when a file is uploaded then causes "orphaned pins" to exist (the previous CID of the folder is still pinned, when a new file is uploaded to it, and there's no way to browse/find that pin again in the UI without reverting the change to the folder in "Files").

I'd be in favor of the logic changing to:

In the "Files" section of the web UI, whenever a new file is added, a background process walks the file tree upward, looking at all the folders that it's contained in. If any of the folders are currently pinned, delete the existing pin and pin the new CID of the updated folder structure.