diff --git a/backend/local.go b/backend/local.go index 5af20e89f..c5368a69b 100644 --- a/backend/local.go +++ b/backend/local.go @@ -187,12 +187,19 @@ type localBlob struct { tpe Type id ID size uint + closed bool } func (lb *localBlob) Close() error { + if lb.closed { + return errors.New("Close() called on closed file") + + } + lb.closed = true + err := lb.f.Close() if err != nil { - return err + return fmt.Errorf("local: file.Close: %v", err) } // get ID diff --git a/backend/sftp.go b/backend/sftp.go index 5961e43f5..712cfc82b 100644 --- a/backend/sftp.go +++ b/backend/sftp.go @@ -297,12 +297,18 @@ type sftpBlob struct { tpe Type id ID size uint + closed bool } func (sb *sftpBlob) Close() error { + if sb.closed { + return errors.New("Close() called on closed file") + } + sb.closed = true + err := sb.f.Close() if err != nil { - return err + return fmt.Errorf("sftp: file.Close: %v", err) } // get ID