summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimport/fetcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/helsinki.at/rhimport/fetcher.go')
-rw-r--r--src/helsinki.at/rhimport/fetcher.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/helsinki.at/rhimport/fetcher.go b/src/helsinki.at/rhimport/fetcher.go
index 1770343..b4e2f0c 100644
--- a/src/helsinki.at/rhimport/fetcher.go
+++ b/src/helsinki.at/rhimport/fetcher.go
@@ -27,6 +27,7 @@ package rhimport
import (
"fmt"
"github.com/golang-basic/go-curl"
+ "io/ioutil"
"mime"
"net/url"
"os"
@@ -95,7 +96,9 @@ func FetchFileCurl(ctx *ImportContext, uri *url.URL) (err error) {
cbdata := &CurlCBData{remotename: path.Base(uri.Path)}
defer cbdata.Cleanup()
- cbdata.basepath = ctx.Config.TempDir // TODO: create temporary directory
+ if cbdata.basepath, err = ioutil.TempDir(ctx.Config.TempDir, "rhimportd-"); err != nil {
+ return
+ }
easy.Setopt(curl.OPT_HEADERFUNCTION, curlHeaderCallback)
easy.Setopt(curl.OPT_HEADERDATA, cbdata)
@@ -121,6 +124,7 @@ func FetchFileCurl(ctx *ImportContext, uri *url.URL) (err error) {
ctx.SourceFile = cbdata.filename
ctx.DeleteSourceFile = true
+ ctx.DeleteSourceDir = true
}
return
}
@@ -129,6 +133,7 @@ func FetchFileLocal(ctx *ImportContext, uri *url.URL) (err error) {
rhl.Printf("Local fetcher called for '%s'", ctx.SourceUri)
ctx.SourceFile = uri.Path
ctx.DeleteSourceFile = false
+ ctx.DeleteSourceDir = false
return
}