diff options
author | Nick White <git@njw.name> | 2020-05-26 16:02:42 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2020-05-26 16:02:42 +0100 |
commit | ed561822b58756c101654946cff0617a6038bc2c (patch) | |
tree | 731a3d61bf4f56b8b9aa91673cfca829bc314efc | |
parent | c80b2b74037297f7a8be5ece015dbdbea2d170f6 (diff) |
Fix DelFromQueue and Upload for local connections
-rw-r--r-- | local.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -1,4 +1,4 @@ -// Copyright 2019 Nick White. +// Copyright 2020 Nick White. // Use of this source code is governed by the GPLv3 // license that can be found in the LICENSE file. @@ -180,7 +180,7 @@ func (a *LocalConn) DelFromQueue(url string, handle string) error { i := strings.Index(s, handle) // store the joining of part before and part after handle - complete := s[0:i] + s[i + len(handle):len(s)] + complete := s[0:i] + s[i + len(handle) + 1:len(s)] f, err := os.Create(filepath.Join(a.TempDir, url)) if err != nil { @@ -210,6 +210,11 @@ func (a *LocalConn) Download(bucket string, key string, path string) error { // Upload just copies the file from path to TempDir/bucket/key func (a *LocalConn) Upload(bucket string, key string, path string) error { + d := filepath.Join(a.TempDir, bucket, filepath.Dir(key)) + err := os.Mkdir(d, 0700) + if err != nil && !os.IsExist(err) { + return fmt.Errorf("Error creating temporary directory: %v", err) + } f, err := os.Create(filepath.Join(a.TempDir, bucket, key)) if err != nil { return err |