summaryrefslogtreecommitdiff
path: root/local.go
diff options
context:
space:
mode:
Diffstat (limited to 'local.go')
-rw-r--r--local.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/local.go b/local.go
index 816b44b..44aea76 100644
--- a/local.go
+++ b/local.go
@@ -215,17 +215,18 @@ func (a *LocalConn) DelFromQueue(url string, handle string) error {
// Download just copies the file from TempDir/bucket/key to path
func (a *LocalConn) Download(bucket string, key string, path string) error {
- f, err := os.Create(path)
+ fin, err := os.Open(filepath.Join(a.TempDir, bucket, key))
if err != nil {
return err
}
- defer f.Close()
+ defer fin.Close()
- fin, err := os.Open(filepath.Join(a.TempDir, bucket, key))
+ f, err := os.Create(path)
if err != nil {
return err
}
- defer fin.Close()
+ defer f.Close()
+
_, err = io.Copy(f, fin)
return err
}