summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-08 17:21:01 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-08 17:21:01 (GMT)
commit092da9dfacbcb5afcd2d3f281f664543ee956f4e (patch)
tree21725ad1d40fb638de938fda1cd86c68dd97752a /rhimport
parent003d2444a73f05f8ef52174298affa190264f003 (diff)
use original fielname for cut/cart title
Diffstat (limited to 'rhimport')
-rw-r--r--rhimport/core.go4
-rw-r--r--rhimport/fetcher.go10
2 files changed, 9 insertions, 5 deletions
diff --git a/rhimport/core.go b/rhimport/core.go
index fcc9584..0e596ba 100644
--- a/rhimport/core.go
+++ b/rhimport/core.go
@@ -129,6 +129,7 @@ type Context struct {
SourceUri string
AttachmentChan <-chan []byte
FetchConverter string
+ OrigFilename string
SourceFile string
DeleteSourceFile bool
DeleteSourceDir bool
@@ -157,6 +158,7 @@ func NewContext(conf *Config, db *rddb.DBChan) *Context {
ctx.UseMetaData = conf.ImportParamDefaults.UseMetaData
ctx.AttachmentChan = nil
ctx.FetchConverter = "ffmpeg"
+ ctx.OrigFilename = ""
ctx.SourceFile = ""
ctx.DeleteSourceFile = false
ctx.DeleteSourceDir = false
@@ -246,5 +248,5 @@ func (ctx *Context) getMusicInfo() (err error) {
}
func (ctx *Context) updateCutCartTitle() (err error) {
- return ctx.db.UpdateCutCartTitle(ctx.Cart, ctx.Cut, ctx.GroupName, ctx.SourceFile)
+ return ctx.db.UpdateCutCartTitle(ctx.Cart, ctx.Cut, ctx.GroupName, ctx.OrigFilename)
}
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go
index 670553f..f40adca 100644
--- a/rhimport/fetcher.go
+++ b/rhimport/fetcher.go
@@ -80,6 +80,7 @@ func curlWriteCallback(ptr []byte, userdata interface{}) bool {
}
data.filename = filepath.Join(data.basepath, name)
}
+ data.ctx.OrigFilename = data.filename
conv, newFilename, err := NewFetchConverter(data.ctx.FetchConverter, data.filename, data.metadata)
if err != nil {
rhl.Printf("Unable to create converter for file %s: %s", data.filename, err)
@@ -354,6 +355,7 @@ func fetchFileDirConvert(ctx *Context, res *Result, origSrc *os.File, sizeTotal
}
origDir, origFile := path.Split(ctx.SourceFile)
+ ctx.OrigFilename = ctx.SourceFile
var conv FetchConverter
if conv, ctx.SourceFile, err = NewFetchConverter(ctx.FetchConverter, filepath.Join(basepath, origFile), nil); err != nil {
rhl.Printf("Unable to create converter for file %s: %s", origDir+origFile, err)
@@ -507,6 +509,7 @@ func fetchFileFake(ctx *Context, res *Result, uri *url.URL) error {
}
}
ctx.SourceFile = "/nonexistend/fake.mp3"
+ ctx.OrigFilename = ctx.SourceFile
if ctx.SourceFilePolicy == Auto {
ctx.DeleteSourceFile = false
ctx.DeleteSourceDir = false
@@ -589,12 +592,11 @@ func fetchFileAttachment(ctx *Context, res *Result, uri *url.URL) error {
ctx.SourceFile = filepath.Join(basepath, path.Clean("/"+uri.Path))
var conv FetchConverter
- var newFilename string
- if conv, newFilename, err = NewFetchConverter(ctx.FetchConverter, ctx.SourceFile, nil); err != nil {
- rhl.Printf("Unable to create converter for file %s: %s", ctx.SourceFile, err)
+ ctx.OrigFilename = ctx.SourceFile
+ if conv, ctx.SourceFile, err = NewFetchConverter(ctx.FetchConverter, ctx.SourceFile, nil); err != nil {
+ rhl.Printf("Unable to create converter for file %s: %s", ctx.OrigFilename, err)
return err
}
- ctx.SourceFile = newFilename
if ctx.ProgressCallBack != nil {
if keep := ctx.ProgressCallBack(1, "receiving", 0.0, float64(sizeTotal), ctx.ProgressCallBackData); !keep {