Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
surfer-okd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PUBLIC
surfer-okd
Commits
a7f450d7
Commit
a7f450d7
authored
Jun 27, 2015
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix delete
parent
bead9e24
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
29 deletions
+3
-29
foobar
files/foobar
+0
-26
files.js
src/files.js
+3
-3
No files found.
files/foobar
deleted
100644 → 0
View file @
bead9e24
{
"name": "surfer",
"version": "1.0.0",
"description": "Simple file server",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"file",
"server"
],
"author": "Johannes Zellner <johannes@nebulon.de>",
"license": "MIT",
"dependencies": {
"body-parser": "^1.13.1",
"compression": "^1.5.0",
"connect-lastmile": "0.0.10",
"connect-timeout": "^1.6.2",
"ejs": "^2.3.1",
"express": "^4.12.4",
"morgan": "^1.6.0",
"multiparty": "^4.1.2",
"rimraf": "^2.4.0"
}
}
src/files.js
View file @
a7f450d7
...
@@ -62,7 +62,7 @@ function get(req, res, next) {
...
@@ -62,7 +62,7 @@ function get(req, res, next) {
fs
.
stat
(
absoluteFilePath
,
function
(
error
,
result
)
{
fs
.
stat
(
absoluteFilePath
,
function
(
error
,
result
)
{
if
(
error
)
return
next
(
new
HttpError
(
404
,
error
));
if
(
error
)
return
next
(
new
HttpError
(
404
,
error
));
console
.
log
(
'get'
,
absoluteFilePath
,
result
);
console
.
log
(
'get'
,
absoluteFilePath
);
if
(
result
.
isFile
())
return
res
.
sendfile
(
absoluteFilePath
);
if
(
result
.
isFile
())
return
res
.
sendfile
(
absoluteFilePath
);
if
(
result
.
isDirectory
())
return
res
.
status
(
200
).
send
({
entries
:
fs
.
readdirSync
(
absoluteFilePath
)
});
if
(
result
.
isDirectory
())
return
res
.
status
(
200
).
send
({
entries
:
fs
.
readdirSync
(
absoluteFilePath
)
});
...
@@ -82,7 +82,7 @@ function put(req, res, next) {
...
@@ -82,7 +82,7 @@ function put(req, res, next) {
fs
.
stat
(
absoluteFilePath
,
function
(
error
,
result
)
{
fs
.
stat
(
absoluteFilePath
,
function
(
error
,
result
)
{
if
(
error
&&
error
.
code
!==
'ENOENT'
)
return
next
(
new
HttpError
(
500
,
error
));
if
(
error
&&
error
.
code
!==
'ENOENT'
)
return
next
(
new
HttpError
(
500
,
error
));
console
.
log
(
'put'
,
absoluteFilePath
,
re
sult
,
re
q
.
files
.
file
);
console
.
log
(
'put'
,
absoluteFilePath
,
req
.
files
.
file
);
if
(
result
&&
result
.
isDirectory
())
return
next
(
new
HttpError
(
409
,
'cannot put on directories'
));
if
(
result
&&
result
.
isDirectory
())
return
next
(
new
HttpError
(
409
,
'cannot put on directories'
));
if
(
!
result
||
result
.
isFile
())
{
if
(
!
result
||
result
.
isFile
())
{
...
@@ -106,7 +106,7 @@ function del(req, res, next) {
...
@@ -106,7 +106,7 @@ function del(req, res, next) {
rimraf
(
absoluteFilePath
,
function
(
error
)
{
rimraf
(
absoluteFilePath
,
function
(
error
)
{
if
(
error
)
return
next
(
new
HttpError
(
500
,
'Unable to remove'
));
if
(
error
)
return
next
(
new
HttpError
(
500
,
'Unable to remove'
));
next
(
new
Http
Error
(
200
,
{}));
next
(
new
Http
Success
(
200
,
{}));
});
});
});
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment