« get me outta code hell

Keep downloaded filename in HTTP downloader - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorliam4 <towerofnix@gmail.com>2017-06-12 12:21:44 +0000
committerliam4 <towerofnix@gmail.com>2017-06-12 12:21:44 +0000
commitbafe90fb6a0c7fcb911df537ef448bbbb9ecf457 (patch)
tree7ec3e5c46b7c1bc2e88154e4265e75a7e80283d4 /src
parentceb4c5959d1a50574029c39252248874ed0fa160 (diff)
Keep downloaded filename in HTTP downloader
Diffstat (limited to 'src')
-rw-r--r--src/downloaders.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/downloaders.js b/src/downloaders.js
index 28dab92..ad322fa 100644
--- a/src/downloaders.js
+++ b/src/downloaders.js
@@ -2,6 +2,7 @@ const fs = require('fs')
 const fetch = require('node-fetch')
 const promisifyProcess = require('./promisify-process')
 const tempy = require('tempy')
+const path = require('path')
 
 const { spawn } = require('child_process')
 const { promisify } = require('util')
@@ -10,7 +11,8 @@ const writeFile = promisify(fs.writeFile)
 
 function makeHTTPDownloader() {
   return function(arg) {
-    const out = tempy.file()
+    const dir = tempy.directory()
+    const out = dir + '/' + path.basename(arg)
 
     return fetch(arg)
       .then(response => response.buffer())