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

Passing multiple Trees as array to nodes to WebDAV Server instance? #146

Open
joeherold opened this issue Mar 11, 2016 · 9 comments
Open

Comments

@joeherold
Copy link

Is it possible to add an array of multiple tree objects to the node attribute?
Idea behind is a CMS business-logic, where in the backend an administrator may define multiple root folders out of a complete tree structure for separate users and groups what they have access to.

// import dependencies
var path = require("path");
var jsDAV = require("jsDAV/lib/jsdav");
var jsDAV_FS_Tree = require("jsDAV/lib/DAV/backends/fs/tree");
var jsDAV_Locks_Backend_FS = require("jsDAV/lib/DAV/plugins/locks/fs");

// file locks
var fileLocks = jsDAV_Locks_Backend_FS.new(__dirname + "/locks/files");

// create an array of trees here
var treeArray = [];
treeArray.push(jsDAV_FS_Tree.new(path.join(__dirname,"/path/to/root1")));
treeArray.push(jsDAV_FS_Tree.new(path.join(__dirname,"/path/to/another/root2")));
treeArray.push(jsDAV_FS_Tree.new(path.join(__dirname,"/path/also/to/another/root3")));

// passing the array... does this work?
jsDAV.createServer({
    node: treeArray, // IS THIS POSSIBLE?
    locksBackend: fileLocks
}, 8000);
@joeherold
Copy link
Author

For the connected Client it should look something like this....

mountpoint (mounted drive in e.g. OSX finder)
     ----- root1
     ----- root2
     ----- root3

@mikedeboer
Copy link
Owner

This is not a tested code flow, but it should be possible: https://github.com/mikedeboer/jsDAV/blob/master/lib/DAV/server.js#L115

This uses https://github.com/mikedeboer/jsDAV/blob/master/lib/DAV/simpleCollection.js and that should work like you describe in your second comment.

If it doesn't work, please show me the terminal output and perhaps a screenshot of your client.

I'm curious 😉

@joeherold
Copy link
Author

Ok. I will try in about an hour. But when I look at your provided link at line 119 a question came up: Does a tree (iTree) implements the iNode features? Probably this will throw an error. But I will check it out. THX

https://github.com/mikedeboer/jsDAV/blob/master/lib/DAV/server.js#L119

@joeherold
Copy link
Author

And one more thing I am interested in asking you: how did you solve that node does not react to all http methods. When you make an console.log of

Var http = require("http");
Console.log(http.METHODS);

There are missing plenty of methods you defined in the cors.js.

How did you resolve this? I don't understand it. 🤓

@mikedeboer
Copy link
Owner

I didn't solve it, NodeJS is just not interested in following standards properly.

@joeherold
Copy link
Author

Ah. Ok. Lol. During a discussion I had with a sails.js developer about exact that topic a pull request for the http parser was opened to implement in node http parser directly.

nodejs/node#5601

@joeherold
Copy link
Author

But it could be resolved by creating a server based on "net" with a custom http parser instead of using "http" module.
But this might be a lot of work...

Net reacts to all requests

@dimitarkolev
Copy link

@joeherold did you managed to find a solution for the multiple trees.

@dimitarkolev
Copy link

dimitarkolev commented Jul 8, 2016

I found a solution. I hope it helps someone else:

        var jsDAV = require("jsDAV/lib/jsdav");
        var jsDAV_Locks_Backend_FS = require("jsDAV/lib/DAV/plugins/locks/fs");
        var jsDAV_FS_Directory = require("jsDAV/lib/DAV/backends/fs/directory")
        jsDAV.createServer({
            node: [jsDAV_FS_Directory.new('/folder1'), jsDAV_FS_Directory.new('/folder2')],
            locksBackend: jsDAV_Locks_Backend_FS.new(__dirname + "/locks/files"),
        }, 8000);
        return Promise.resolve();

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

No branches or pull requests

3 participants