Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 13080980
authored
Mar 01, 2016
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send more folder listing details
1 parent
898fe7c8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
cli/actions.js
src/files.js
cli/actions.js
View file @
1308098
...
@@ -153,9 +153,9 @@ function get(filePath) {
...
@@ -153,9 +153,9 @@ function get(filePath) {
if
(
!
files
||
files
.
entries
.
length
===
0
)
{
if
(
!
files
||
files
.
entries
.
length
===
0
)
{
console
.
log
(
'No files on the server. Use %s to upload some.'
,
'surfer put <file>'
.
yellow
);
console
.
log
(
'No files on the server. Use %s to upload some.'
,
'surfer put <file>'
.
yellow
);
}
else
{
}
else
{
console
.
log
(
'
Fil
es:'
);
console
.
log
(
'
Entri
es:'
);
files
.
entries
.
forEach
(
function
(
entry
)
{
files
.
entries
.
forEach
(
function
(
entry
)
{
console
.
log
(
'\t %s'
,
entry
);
console
.
log
(
'\t %s'
,
entry
.
isDirectory
?
entry
.
filePath
+
'/'
:
entry
.
filePath
);
});
});
}
}
}
else
{
}
else
{
...
...
src/files.js
View file @
1308098
'use strict'
;
'use strict'
;
var
fs
=
require
(
'fs'
),
var
async
=
require
(
'async'
),
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
path
=
require
(
'path'
),
rm
=
require
(
'del'
),
rm
=
require
(
'del'
),
debug
=
require
(
'debug'
)(
'files'
),
debug
=
require
(
'debug'
)(
'files'
),
...
@@ -74,10 +75,28 @@ function get(req, res, next) {
...
@@ -74,10 +75,28 @@ function get(req, res, next) {
debug
(
'get'
,
absoluteFilePath
);
debug
(
'get'
,
absoluteFilePath
);
if
(
!
result
.
isDirectory
()
&&
!
result
.
isFile
())
return
next
(
new
HttpError
(
500
,
'unsupported type'
));
if
(
result
.
isFile
())
return
res
.
sendFile
(
absoluteFilePath
);
if
(
result
.
isFile
())
return
res
.
sendFile
(
absoluteFilePath
);
if
(
result
.
isDirectory
())
return
res
.
status
(
222
).
send
({
entries
:
fs
.
readdirSync
(
absoluteFilePath
)
});
return
next
(
new
HttpError
(
500
,
'unsupported type'
));
async
.
map
(
fs
.
readdirSync
(
absoluteFilePath
),
function
(
filePath
,
callback
)
{
fs
.
stat
(
path
.
join
(
absoluteFilePath
,
filePath
),
function
(
error
,
result
)
{
if
(
error
)
return
callback
(
error
);
callback
(
null
,
{
isDirectory
:
result
.
isDirectory
(),
isFile
:
result
.
isFile
(),
atime
:
result
.
atime
,
mtime
:
result
.
mtime
,
ctime
:
result
.
ctime
,
birthtime
:
result
.
birthtime
,
size
:
result
.
size
,
filePath
:
filePath
});
});
},
function
(
error
,
results
)
{
if
(
error
)
return
next
(
new
HttpError
(
500
,
error
));
res
.
status
(
222
).
send
({
entries
:
results
});
});
});
});
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment