forked from TrueCloudLab/restic
Remove closing logic from Packer.Finalize
The method only ever receives *hashing.Writers, which don't implement io.Closer. These come from packerManager.findPacker and have their actual writers closed in Repository.savePacker. Moving the closing logic to hashing.Writer results in "file already closed" errors.
This commit is contained in:
parent
c542a509f0
commit
a23e9c86ba
1 changed files with 1 additions and 7 deletions
|
@ -61,8 +61,7 @@ type headerEntry struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalize writes the header for all added blobs and finalizes the pack.
|
// Finalize writes the header for all added blobs and finalizes the pack.
|
||||||
// Returned are the number of bytes written, including the header. If the
|
// Returned are the number of bytes written, including the header.
|
||||||
// underlying writer implements io.Closer, it is closed.
|
|
||||||
func (p *Packer) Finalize() (uint, error) {
|
func (p *Packer) Finalize() (uint, error) {
|
||||||
p.m.Lock()
|
p.m.Lock()
|
||||||
defer p.m.Unlock()
|
defer p.m.Unlock()
|
||||||
|
@ -101,11 +100,6 @@ func (p *Packer) Finalize() (uint, error) {
|
||||||
bytesWritten += uint(binary.Size(uint32(0)))
|
bytesWritten += uint(binary.Size(uint32(0)))
|
||||||
|
|
||||||
p.bytes = uint(bytesWritten)
|
p.bytes = uint(bytesWritten)
|
||||||
|
|
||||||
if w, ok := p.wr.(io.Closer); ok {
|
|
||||||
return bytesWritten, w.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
return bytesWritten, nil
|
return bytesWritten, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue