-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Use VFS abstraction for all filesystem access #1460
Comments
There should be other motivation behind this than it "makes it much easier to use hugo as a library". What do you base the "more common vfs.FileSystem instead of afero" on? |
To expand on the motivation, I want to run Hugo on-the-fly in my existing Go process to process a large number of untrusted sites. I want to avoid hitting disk (even temp dirs) to reduce the resource consumption and have greater certainty that a malicious site can't write to arbitrary locations on my actual filesystem. I thought the motivation would be self-explanatory because it appears someone went halfway to making all FS access go via a VFS. I imagine they stopped for lack of time, so I'm proposing to finish it. I said that vfs.FileSystem is more common because I've heard about a lot more people using it, anecdotally. It appears the data are inconclusive, though: godoc/vfs has 59 importers and afero has 39 importers, but there are many forks and so I can't say for sure. (Also, I know of some implicit interface users of godoc/vfs that aren't explicit importers, such as github.com/kr/fs.) My personal preference would be to go with godoc/vfs because it has Lstat, still seems more popular, it is created by the Go authors, and it's simpler/smaller. But I'm fine sticking with afero. |
It should be really easy to modify Hugo to avoid hitting disk completely. I'm not very familiar with VFS and want to look into it more. I spent a bit I see what you are saying, and I could totally misunderstand the current Steve Francia On Sat, Sep 26, 2015 at 5:43 AM, Quinn Slack notifications@github.com
|
Hey Steve, there are still some places that use Ignore what I said about VFS--that just confused things. Sticking with afero is great. But the issue in the paragraph above still remains. |
That's great. I think we should merge it in. It would be great to have Hugo Steve Francia On Sat, Sep 26, 2015 at 2:54 PM, Quinn Slack notifications@github.com
|
Yea, well, this is obviously a work in progress and not mergeable as-is. (I see some breaking changes (the large portions of out-commented code)). My motivation with all of this is to ease integration testing without needing the file system. So a solid pull request is welcomed, a one that does not add any trouble or work. A comment on the code: I think the |
I should have been more clear. I meant I think this direction is right and Steve Francia On Sat, Sep 26, 2015 at 4:42 PM, Bjørn Erik Pedersen <
|
So, @sqs -- any update/progress on this? |
Not yet, sorry. |
@sqs I am closing this as stale if is OK by you? |
👍 Sounds good.
|
@sqs do you still have the wip code available? I just found some additional motivation and could use a springboard. Product version not of interest. |
@JHabdas Sorry, I must have deleted it. I can’t find it in any local clones or on GitHub. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Some places in hugo still access the filesystem directly (e.g., via package
os
) instead of through the hugofs VFSes.I have a WIP sqs/vfs branch that partially addresses this issue, but there will likely be some loss in functionality (e.g., ExpandSymlinks may not be possible with VFSes...not sure without looking into it further).
@spf13:
Would you accept a PR that makes all FS access go via a VFS in hugofs?
Would you be OK using the more common vfs.FileSystem instead of afero?
Motivation: Using the VFS abstraction everywhere makes it much easier to use hugo as a library.
The text was updated successfully, but these errors were encountered: