diff options
author | Christian Pointner <equinox@spreadspace.org> | 2016-03-12 18:28:32 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2016-03-12 18:28:32 (GMT) |
commit | e78b3cc629ff230ddb3479a036c1858a76ee7f5a (patch) | |
tree | d8f2de86aca1aae1eaf8b7be22773f9ac09921de /rhimport | |
parent | 453d7f9e7311b28802b194640792e2689073590c (diff) |
returning next sourceuri when filepolicy = keep
Diffstat (limited to 'rhimport')
-rw-r--r-- | rhimport/fetcher.go | 13 | ||||
-rw-r--r-- | rhimport/importer.go | 7 |
2 files changed, 17 insertions, 3 deletions
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go index dd4b6df..f501bc6 100644 --- a/rhimport/fetcher.go +++ b/rhimport/fetcher.go @@ -265,14 +265,22 @@ func fetchFileArchiv(ctx *Context, res *Result, uri *url.URL) (err error) { } func fetchFileLocal(ctx *Context, res *Result, uri *url.URL) (err error) { - rhl.Printf("Local fetcher called for '%s'", ctx.SourceUri) + return fetchFileDir(ctx, res, uri, ctx.conf.LocalFetchDir) +} + +func fetchFileTmp(ctx *Context, res *Result, uri *url.URL) (err error) { + return fetchFileDir(ctx, res, uri, ctx.conf.TempDir) +} + +func fetchFileDir(ctx *Context, res *Result, uri *url.URL, dir string) (err error) { + rhl.Printf("Dir fetcher called for '%s'", ctx.SourceUri) if ctx.ProgressCallBack != nil { if keep := ctx.ProgressCallBack(1, "fetching", 0.0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } - ctx.SourceFile = filepath.Join(ctx.conf.LocalFetchDir, path.Clean("/"+uri.Path)) + ctx.SourceFile = filepath.Join(dir, path.Clean("/"+uri.Path)) var src *os.File if src, err = os.Open(ctx.SourceFile); err != nil { res.ResponseCode = http.StatusBadRequest @@ -347,6 +355,7 @@ type FetchFunc func(*Context, *Result, *url.URL) (err error) var ( fetchers = map[string]FetchFunc{ "local": fetchFileLocal, + "tmp": fetchFileTmp, "fake": fetchFileFake, } curlProtos = map[string]bool{ diff --git a/rhimport/importer.go b/rhimport/importer.go index c840bae..952f75a 100644 --- a/rhimport/importer.go +++ b/rhimport/importer.go @@ -32,6 +32,7 @@ import ( "net/http" "os" "path" + "strings" "github.com/andelf/go-curl" ) @@ -425,7 +426,11 @@ func cleanupFiles(ctx *Context, res *Result) { } } } else { - res.SourceFile = ctx.SourceFile + if strings.HasPrefix(ctx.SourceFile, ctx.conf.LocalFetchDir) { + res.SourceFile = "local://" + strings.TrimPrefix(ctx.SourceFile, ctx.conf.LocalFetchDir) + } else if strings.HasPrefix(ctx.SourceFile, ctx.conf.TempDir) { + res.SourceFile = "tmp://" + strings.TrimPrefix(ctx.SourceFile, ctx.conf.TempDir) + } } return } |