Skip to content

Commit

Permalink
Fixed bug that mangled hidden files in FTP
Browse files Browse the repository at this point in the history
  • Loading branch information
sergi committed Sep 15, 2011
1 parent 3306c1d commit d4bb67d
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions lib/DAV/handler.js
Expand Up @@ -37,7 +37,7 @@ function jsDAV_Handler(server, req, resp) {
this.httpRequest = Util.streamBuffer(req);
this.httpResponse = resp;
this.plugins = {};

for (var plugin in server.plugins)
this.plugins[plugin] = new server.plugins[plugin](this);

Expand Down Expand Up @@ -658,7 +658,7 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
this.httpPut = function() {
var _self = this,
uri = this.getRequestUri();

this.getRequestBody("binary", function(err, body, cleanup) {
if (!Util.empty(err))
return _self.handleError(err);
Expand Down Expand Up @@ -838,7 +838,7 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
if (!Util.empty(err))
return _self.handleError(err);

_self.dispatchEvent("afterBind", moveInfo["destination"],
_self.dispatchEvent("afterBind", moveInfo["destination"],
Path.join(_self.server.tree.basePath, moveInfo["destination"]));
// If a resource was overwritten we should send a 204, otherwise a 201
_self.httpResponse.writeHead(moveInfo["destinationExists"] ? 204 : 201,
Expand Down Expand Up @@ -887,7 +887,7 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
_self.server.tree.copy(copyInfo["source"], copyInfo["destination"], function(err) {
if (!Util.empty(err))
return _self.handleError(err);
_self.dispatchEvent("afterBind", copyInfo["destination"],
_self.dispatchEvent("afterBind", copyInfo["destination"],
Path.join(_self.server.tree.basePath, copyInfo["destination"]));

// If a resource was overwritten we should send a 204, otherwise a 201
Expand Down Expand Up @@ -974,7 +974,7 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";

/**
* Fetch the binary data for the HTTP request and return it to a callback.
*
*
* @param {Function} callback
* @return {void}
*/
Expand All @@ -986,7 +986,7 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
cleanup = function() {},
_self = this;

// HACK: MacOSX Finder and NodeJS don't play nice together with files
// HACK: MacOSX Finder and NodeJS don't play nice together with files
// that start with '._'
//if (/\/\.[D_]{1}[^\/]+$/.test(req.url))
// return cbreqbody(null, "", cleanup);
Expand All @@ -996,13 +996,13 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
enc = "binary";
if (req.$data) {
return cbreqbody(null, enc == "binary"
? req.$data
? req.$data
: req.$data.toString(enc), cleanup);
}

if (isStream) {
var stream = [];

req.streambuffer.ondata(function(data) {
stream.push(data);
});
Expand All @@ -1011,7 +1011,7 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
_self.$reading = false;
req.$data = Util.concatBuffers(stream);
readDone(null, enc == "binary"
? req.$data
? req.$data
: req.$data.toString(enc), cleanup);
});
}
Expand All @@ -1034,7 +1034,7 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";

form.parse(req);
}

function readDone(err, data, cleanup) {
cbreqbody(err, data, cleanup);
}
Expand All @@ -1053,9 +1053,9 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
uri = Url.parse(uri).pathname;
else if (uri.indexOf("?") > -1)
uri = Url.parse(uri).pathname;

uri = uri.replace("//", "/");

if (uri.indexOf(this.server.baseUri) === 0) {
return Util.trim(decodeURI(uri.substr(this.server.baseUri.length)), "/");
}
Expand Down Expand Up @@ -1367,7 +1367,7 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
this.getPropertiesForPath = function(path, propertyNames, depth, cbgetpropspath) {
propertyNames = propertyNames || [];
depth = depth || 0;

if (depth !== 0)
depth = 1;

Expand All @@ -1394,7 +1394,6 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
afterGetChildren(nodes);
}


function afterGetChildren(nodes) {
// If the propertyNames array is empty, it means all properties are requested.
// We shouldn't actually return everything we know though, and only return a
Expand All @@ -1412,9 +1411,10 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
// correct href when mountpoint is different than the
// absolute location of the path
var s = Util.trim(_self.server.tree.basePath, "/");
rpath = s.indexOf(_self.server.baseUri) !== 0
? rpath.replace(new RegExp("^" + Util.escapeRegExp(s)), "").replace(/^[\/]+/, "")
: rpath;
if (s.charAt(0) != ".")
rpath = s.indexOf(_self.server.baseUri) !== 0
? rpath.replace(new RegExp("^" + Util.escapeRegExp(s)), "").replace(/^[\/]+/, "")
: rpath;
}
newProps["href"] = rpath;

Expand Down

0 comments on commit d4bb67d

Please sign in to comment.