summaryrefslogtreecommitdiff
path: root/rhimport/core.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-08-04 00:47:07 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-08-04 00:47:12 (GMT)
commit9d1a296bb18bd343f133326bd2eb4b2b3368bf65 (patch)
tree088a3723aff297157e7cd73e11ca4cea202f1b63 /rhimport/core.go
parente3c391263a0bf57db8b7c1566a27de9cdc325647 (diff)
temporary work dir is now handled by session (no support for soure file policy for now)
Diffstat (limited to 'rhimport/core.go')
-rw-r--r--rhimport/core.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/rhimport/core.go b/rhimport/core.go
index 6afcd9f..dae4b34 100644
--- a/rhimport/core.go
+++ b/rhimport/core.go
@@ -160,9 +160,8 @@ type Context struct {
ExtraMetaData map[string]string
OrigFilename string
Title string
+ WorkDir string
SourceFile string
- DeleteSourceFile bool
- DeleteSourceDir bool
SourceFilePolicy FilePolicy
LoudnessCorr float64
ProgressCallBack ProgressCB
@@ -202,8 +201,6 @@ func NewContext(conf *Config, db *rddb.DB, stdlog, dbglog *log.Logger) *Context
ctx.OrigFilename = ""
ctx.Title = ""
ctx.SourceFile = ""
- ctx.DeleteSourceFile = false
- ctx.DeleteSourceDir = false
ctx.LoudnessCorr = 0.0
ctx.SourceFilePolicy = Auto
ctx.ProgressCallBack = nil
@@ -267,6 +264,19 @@ func (ctx *Context) SanityCheck() error {
return nil
}
+func (ctx *Context) CreateTempWorkDir() (err error) {
+ ctx.WorkDir, err = ioutil.TempDir(ctx.conf.TempDir, "rhimport-")
+ return
+}
+
+func (ctx *Context) RemoveTempWorkDir() {
+ // check File Policy!!!
+ if err := os.RemoveAll(ctx.WorkDir); err != nil {
+ ctx.stdlog.Printf("Error removing WorkDir: %s", err)
+ }
+ return
+}
+
func (ctx *Context) getPassword(cached bool) (err error) {
ctx.Password, err = ctx.db.GetPassword(ctx.UserName, cached)
return