From 5d617edbbf0c0cf7722709c13eb36e700d70fdb3 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 25 Oct 2015 17:51:26 +0100 Subject: [PATCH] local/sftp backend: Do not seek if offset is 0 --- backend/local/local.go | 8 +++++--- backend/sftp/sftp.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/local/local.go b/backend/local/local.go index 487397353..ffcfe68d6 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -223,9 +223,11 @@ func (b *Local) GetReader(t backend.Type, name string, offset, length uint) (io. b.open[filename(b.p, t, name)] = append(open, f) b.mu.Unlock() - _, err = f.Seek(int64(offset), 0) - if err != nil { - return nil, err + if offset > 0 { + _, err = f.Seek(int64(offset), 0) + if err != nil { + return nil, err + } } if length == 0 { diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go index 13bd54340..c904bf4bc 100644 --- a/backend/sftp/sftp.go +++ b/backend/sftp/sftp.go @@ -336,9 +336,11 @@ func (r *SFTP) GetReader(t backend.Type, name string, offset, length uint) (io.R return nil, err } - _, err = f.Seek(int64(offset), 0) - if err != nil { - return nil, err + if offset > 0 { + _, err = f.Seek(int64(offset), 0) + if err != nil { + return nil, err + } } if length == 0 {