2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-26 20:30:19 +00:00

backend: Throw error when Close() is called twice

This commit is contained in:
Alexander Neumann 2015-02-16 00:24:02 +01:00
parent 259389f7d1
commit b816192d1c
2 changed files with 15 additions and 2 deletions

View File

@ -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

View File

@ -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