forked from TrueCloudLab/restic
backend: Throw error when Close() is called twice
This commit is contained in:
parent
259389f7d1
commit
b816192d1c
2 changed files with 15 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue