summaryrefslogtreecommitdiff
path: root/local.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-05-26 16:02:42 +0100
committerNick White <git@njw.name>2020-05-26 16:02:42 +0100
commited561822b58756c101654946cff0617a6038bc2c (patch)
tree731a3d61bf4f56b8b9aa91673cfca829bc314efc /local.go
parentc80b2b74037297f7a8be5ece015dbdbea2d170f6 (diff)
Fix DelFromQueue and Upload for local connections
Diffstat (limited to 'local.go')
-rw-r--r--local.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/local.go b/local.go
index 5e21b19..70991b2 100644
--- a/local.go
+++ b/local.go
@@ -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