Commit 994d5513 authored by Leo Iannacone's avatar Leo Iannacone

always download log files (and dsc, changes) and set text/plain as content-type to compress them

parent 0c77a1cb
......@@ -70,6 +70,15 @@ if config.routes.debomatic
res.set('Content-Type', 'text/plain')
next()
# always download log files and some source files, like .dsc and .changes ones
app.all config.routes.debomatic + '/:distribution/pool/:package/:file', (req, res, next) ->
type = utils.file_type(req.params.file)
ext = req.params.file.split('.').pop()
if type is "log" or ext in ["changes", "dsc"]
res.set('Content-Type', 'text/plain')
res.set('Content-Disposition', 'attachment; filename=' + req.params.file)
next()
app.use(config.routes.debomatic, serve_static(config.debomatic.path))
app.use(config.routes.debomatic, serve_index(config.debomatic.path,
{view: "details", icons: true}))
......@@ -77,9 +86,6 @@ if config.routes.debomatic
# serve stylesheet-javascript
app.use(serve_static(__dirname + "/../public"))
# serve dsc files as octet-stream
serve_static.mime.define("application/octet-stream": ["dsc"])
# Listening
server.listen config.port, config.host, null, (err) ->
......
......@@ -20,9 +20,10 @@ get_files_list_from_package = (data, callback) ->
config.routes.debomatic)
file.orig_name = f
file.name = f.split("_")[0]
if file.extension in ["deb", "ddeb", "udeb"]
type = utils.file_type(f)
if type is "deb"
data.package.debs.push(file)
else if file.extension in ["changes", "dsc"] or f.indexOf('.tar.') > 0 or f.indexOf('.diff.') > 0
else if type is "source"
file.name = f.replace(data.package.orig_name + ".", "")
if file.extension is "changes"
file.name = f.split('_').pop()
......
......@@ -117,6 +117,14 @@ errors_handler = (from, err, socket) ->
socket.emit config.events.error, msg if socket
return
file_type = (filename) ->
extension = filename.split(".").pop()
if extension in ["deb", "ddeb", "udeb"]
return "deb"
if extension in ["changes", "dsc"] or filename.indexOf('.tar.') > 0 or filename.indexOf('.diff.') > 0
return "source"
return "log"
Tail::watchEvent = (e) ->
_this = this
if e is "change"
......@@ -152,5 +160,6 @@ module.exports.get_file_path = get_file_path
module.exports.get_files_list = get_files_list
module.exports.watch_path_onsocket = watch_path_onsocket
module.exports.errors_handler = errors_handler
module.exports.file_type = file_type
module.exports.arrayEqual = arrayEqual
module.exports.Tail = Tail
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment