diff options
author | Johannes Zellner <johannes@nebulon.de> | 2015-06-27 15:41:43 +0200 |
---|---|---|
committer | Johannes Zellner <johannes@nebulon.de> | 2015-06-27 15:41:43 +0200 |
commit | a7f450d7b80feb2c7125813aee56ee6519b33228 (patch) | |
tree | 60eeb8d6ce9e0114648f46d20b50264e08abc348 | |
parent | bead9e2436736ab72cb4eef3596746cb3c55e8d5 (diff) | |
download | Surfer-a7f450d7b80feb2c7125813aee56ee6519b33228.tar.gz Surfer-a7f450d7b80feb2c7125813aee56ee6519b33228.tar.zst Surfer-a7f450d7b80feb2c7125813aee56ee6519b33228.zip |
Fix delete
-rw-r--r-- | files/foobar | 26 | ||||
-rw-r--r-- | src/files.js | 6 |
2 files changed, 3 insertions, 29 deletions
diff --git a/files/foobar b/files/foobar deleted file mode 100644 index cf08457..0000000 --- a/files/foobar +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | { | ||
2 | "name": "surfer", | ||
3 | "version": "1.0.0", | ||
4 | "description": "Simple file server", | ||
5 | "main": "app.js", | ||
6 | "scripts": { | ||
7 | "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | }, | ||
9 | "keywords": [ | ||
10 | "file", | ||
11 | "server" | ||
12 | ], | ||
13 | "author": "Johannes Zellner <johannes@nebulon.de>", | ||
14 | "license": "MIT", | ||
15 | "dependencies": { | ||
16 | "body-parser": "^1.13.1", | ||
17 | "compression": "^1.5.0", | ||
18 | "connect-lastmile": "0.0.10", | ||
19 | "connect-timeout": "^1.6.2", | ||
20 | "ejs": "^2.3.1", | ||
21 | "express": "^4.12.4", | ||
22 | "morgan": "^1.6.0", | ||
23 | "multiparty": "^4.1.2", | ||
24 | "rimraf": "^2.4.0" | ||
25 | } | ||
26 | } | ||
diff --git a/src/files.js b/src/files.js index fd9c8fd..55e8978 100644 --- a/src/files.js +++ b/src/files.js | |||
@@ -62,7 +62,7 @@ function get(req, res, next) { | |||
62 | fs.stat(absoluteFilePath, function (error, result) { | 62 | fs.stat(absoluteFilePath, function (error, result) { |
63 | if (error) return next(new HttpError(404, error)); | 63 | if (error) return next(new HttpError(404, error)); |
64 | 64 | ||
65 | console.log('get', absoluteFilePath, result); | 65 | console.log('get', absoluteFilePath); |
66 | 66 | ||
67 | if (result.isFile()) return res.sendfile(absoluteFilePath); | 67 | if (result.isFile()) return res.sendfile(absoluteFilePath); |
68 | if (result.isDirectory()) return res.status(200).send({ entries: fs.readdirSync(absoluteFilePath) }); | 68 | if (result.isDirectory()) return res.status(200).send({ entries: fs.readdirSync(absoluteFilePath) }); |
@@ -82,7 +82,7 @@ function put(req, res, next) { | |||
82 | fs.stat(absoluteFilePath, function (error, result) { | 82 | fs.stat(absoluteFilePath, function (error, result) { |
83 | if (error && error.code !== 'ENOENT') return next(new HttpError(500, error)); | 83 | if (error && error.code !== 'ENOENT') return next(new HttpError(500, error)); |
84 | 84 | ||
85 | console.log('put', absoluteFilePath, result, req.files.file); | 85 | console.log('put', absoluteFilePath, req.files.file); |
86 | 86 | ||
87 | if (result && result.isDirectory()) return next(new HttpError(409, 'cannot put on directories')); | 87 | if (result && result.isDirectory()) return next(new HttpError(409, 'cannot put on directories')); |
88 | if (!result || result.isFile()) { | 88 | if (!result || result.isFile()) { |
@@ -106,7 +106,7 @@ function del(req, res, next) { | |||
106 | 106 | ||
107 | rimraf(absoluteFilePath, function (error) { | 107 | rimraf(absoluteFilePath, function (error) { |
108 | if (error) return next(new HttpError(500, 'Unable to remove')); | 108 | if (error) return next(new HttpError(500, 'Unable to remove')); |
109 | next(new HttpError(200, {})); | 109 | next(new HttpSuccess(200, {})); |
110 | }); | 110 | }); |
111 | }); | 111 | }); |
112 | } | 112 | } |