Skip to content

Commit

Permalink
Merge branch 'master' of http://github.com/ajaxorg/jsDAV
Browse files Browse the repository at this point in the history
  • Loading branch information
linh81 committed Aug 16, 2011
2 parents d35e74c + 401348b commit cc572e7
Show file tree
Hide file tree
Showing 20 changed files with 938 additions and 228 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
[submodule "support/node-sftp"]
path = support/node-sftp
url = git://github.com/ajaxorg/node-sftp.git
[submodule "support/node-ssh"]
path = support/node-ssh
url = git://github.com/ajaxorg/node-ssh.git
[submodule "support/node-ftp"]
path = support/node-ftp
url = git://github.com/ajaxorg/node-ftp.git
54 changes: 43 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,49 @@ jsDAV
jsDAV allows you to easily add WebDAV support to a NodeJS application.
jsDAV is meant to cover the entire standard, and attempts to allow integration using an easy to understand API.

Short story
-----------

TODO

Usage
-----

TODO


Features
--------

* Fully WebDAV compliant
* Supports Windows XP, Windows Vista, Mac OS/X, DavFSv2, Cadaver, Netdrive, Open Office, and probably more
* Supporting class 1, 2 and 3 Webdav servers
* Custom property support

Features in development
-----------------------

* Locking support (feature complete, but untested)
* Pass all Litmus tests
* CalDAV (to be tested with Evolution, iCal, iPhone and Lightning).

Supported RFC's
---------------

* [RFC2617]: Basic/Digest auth
* [RFC2518]: First WebDAV spec
* [RFC4709]: [DavMount]
* [RFC5397]: current-user-principal
* [RFC5689]: Extended MKCOL

RFC's in development
--------------------

* [RFC3744]: ACL
* [RFC4791]: CalDAV
* [RFC4918]: WebDAV revision
* CalDAV ctag, CalDAV-proxy

[RFC2617]: http://www.ietf.org/rfc/rfc2617.txt
[RFC2518]: http://www.ietf.org/rfc/rfc2518.txt
[RFC3744]: http://www.ietf.org/rfc/rfc3744.txt
[RFC4709]: http://www.ietf.org/rfc/rfc4709.txt
[DavMount]: http://code.google.com/p/sabredav/wiki/DavMount
[RFC4791]: http://www.ietf.org/rfc/rfc4791.txt
[RFC4918]: http://www.ietf.org/rfc/rfc4918.txt
[RFC5397]: http://www.ietf.org/rfc/rfc5689.txt
[RFC5689]: http://www.ietf.org/rfc/rfc5689.txt

See the [wiki](https://github.com/mikedeboer/jsDAV/wiki) for more information!


Amsterdam, 2010. Mike de Boer.
2 changes: 1 addition & 1 deletion lib/DAV/exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ exports.jsDAV_Exception = function(msg, extra) {
}
};
};
exports.jsDAV_Exception.prototype = Error.prototype;
exports.jsDAV_Exception.prototype = new Error();

/**
* BadRequest
Expand Down
50 changes: 24 additions & 26 deletions lib/DAV/ftp/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var jsDAV = require("./../../jsdav"),
Exc = require("./../exceptions");

function jsDAV_Ftp_Directory(path, ftp) {
this.path = (path || "").replace(/\s+[\/]+$/, "");
this.path = path || "";
this.ftp = ftp;
}

Expand All @@ -38,7 +38,7 @@ exports.jsDAV_Ftp_Directory = jsDAV_Ftp_Directory;
* @return void
*/
this.createFile = function(name, data, enc, cbftpcreatefile) {
var newPath = (this.path + "/" + name).replace(/[\/]+$/, "");
var newPath = Util.trim(this.path + "/" + name, "/");
if (data.length === 0) { //ftp lib does not support writing empty files...
data = new Buffer("empty file");
enc = "binary";
Expand All @@ -60,25 +60,20 @@ exports.jsDAV_Ftp_Directory = jsDAV_Ftp_Directory;
* @return void
*/
this.createDirectory = function(name, cbftpcreatedir) {
var newPath = this.path + "/" + name.replace(/[\/]+$/, "");
var newPath = Util.trim(this.path + "/" + name, "/");
var self = this;
var mkdir = this.ftp.mkdir(newPath, function(err) {
this.ftp.mkdir(newPath, function(err) {
if (err)
return cbftpcreatedir(err);

var chmod = self.ftp.chmod(newPath, 755, function(err) {
if (err)
return cbftpcreatedir(err);
self.ftp.chmod(newPath, 755, function(err) {
// Not strictly necessary, bypassing error...
/*if (err)
return cbftpcreatedir(err);*/

cbftpcreatedir(null, new jsDAV_Ftp_Directory(newPath, self.ftp));
});
if (!chmod)
cbftpcreatedir(new Exc.jsDAV_Exception_NotImplemented("Could not create directory in "
+ newPath + ". User not authorized or command CHMOD not implemented."));
});
if (!mkdir)
cbftpcreatedir(new Exc.jsDAV_Exception_NotImplemented("Could not create directory in "
+ newPath + ". User not authorized or command MKDIR not allowed."));
};

/**
Expand All @@ -92,7 +87,7 @@ exports.jsDAV_Ftp_Directory = jsDAV_Ftp_Directory;
if (typeof stat !== "object")
return cbftpgetchild(new Exc.jsDAV_Exception_FileNotFound("Child node could not be retrieved"));

var path = (this.path + "/" + stat.name).replace(/[\/]+$/, "");
var path = Util.trim(this.path + "/" + stat.name, "/");

if (this.ftp.$cache[path])
return cbftpgetchild(null, this.ftp.$cache[path]);
Expand All @@ -112,25 +107,28 @@ exports.jsDAV_Ftp_Directory = jsDAV_Ftp_Directory;
* @return Sabre_DAV_INode[]
*/
this.getChildren = function(cbftpgetchildren) {
var nodes = [], self = this;
var nodes = [], _self = this;

this.ftp.readdir(this.path, function(err, listing) {
if (err)
return cbftpgetchildren(err);
if (!listing)
return cbftpgetchildren(null, nodes);

Async.list(listing).each(function(node, next) {
self.getChild(node, function(err, node) {
if (err)
return next();

nodes.push(node);
next();

Async.list(listing)
.delay(0, 30)
.each(function(node, next) {
_self.getChild(node, function(err, node) {
if (err)
return next();

nodes.push(node);
next();
});
})
.end(function() {
cbftpgetchildren(null, nodes);
});
}).end(function() {
cbftpgetchildren(null, nodes);
});
});
};

Expand Down
6 changes: 3 additions & 3 deletions lib/DAV/ftp/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var jsDAV = require("./../../jsdav"),
Util = require("./../util");

function jsDAV_Ftp_File(path, ftp) {
this.path = (path || "").replace(/[\/]+$/, "");
this.path = path || "";
this.ftp = ftp;
}

Expand All @@ -41,7 +41,7 @@ exports.jsDAV_Ftp_File = jsDAV_Ftp_File;
if (err)
return cbftpput(err);
// @todo what about parent node's cache??
delete self.ftp.$cache[this.path];
delete self.ftp.$cache[self.path];
cbftpput();
});
};
Expand Down Expand Up @@ -81,7 +81,7 @@ exports.jsDAV_Ftp_File = jsDAV_Ftp_File;
*/
this.getSize = function(cbftpgetsize) {
var bytes = this.ftp.$cache[this.path].$stat.size;
cbftpgetsize(bytes);
cbftpgetsize(null, bytes);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/DAV/ftp/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ exports.jsDAV_Ftp_Node = jsDAV_Ftp_Node;
};

this.$isRoot = function() {
return this.hasFeature(jsDAV.__ICOLLECTION__) && this.path === "";
return this.hasFeature(jsDAV.__ICOLLECTION__) && this.isRoot === true;
};

/**
Expand Down
Loading

0 comments on commit cc572e7

Please sign in to comment.