mirror of
https://github.com/restic/restic.git
synced 2025-01-03 13:45:20 +00:00
Correctly deal with empty files
This commit is contained in:
parent
6d56d7d4c6
commit
c0b3021494
3 changed files with 6 additions and 6 deletions
10
archiver.go
10
archiver.go
|
@ -167,13 +167,13 @@ func (arch *Archiver) SaveFile(node *Node) error {
|
||||||
buf := GetChunkBuf("blob single file")
|
buf := GetChunkBuf("blob single file")
|
||||||
defer FreeChunkBuf("blob single file", buf)
|
defer FreeChunkBuf("blob single file", buf)
|
||||||
n, err := io.ReadFull(file, buf)
|
n, err := io.ReadFull(file, buf)
|
||||||
if err != nil && err != io.ErrUnexpectedEOF {
|
if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
|
||||||
return err
|
return arrar.Annotate(err, "SaveFile() read small file")
|
||||||
}
|
}
|
||||||
|
|
||||||
blob, err := arch.ch.Save(backend.Data, buf[:n])
|
blob, err := arch.ch.Save(backend.Data, buf[:n])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return arrar.Annotate(err, "SaveFile() save chunk")
|
||||||
}
|
}
|
||||||
|
|
||||||
arch.update(arch.SaveStats, Stats{Bytes: blob.Size})
|
arch.update(arch.SaveStats, Stats{Bytes: blob.Size})
|
||||||
|
@ -195,7 +195,7 @@ func (arch *Archiver) SaveFile(node *Node) error {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
FreeChunkBuf("blob chunker", buf)
|
FreeChunkBuf("blob chunker", buf)
|
||||||
return err
|
return arrar.Annotate(err, "SaveFile() chunker.Next()")
|
||||||
}
|
}
|
||||||
|
|
||||||
// acquire token, start goroutine to save chunk
|
// acquire token, start goroutine to save chunk
|
||||||
|
@ -231,7 +231,7 @@ func (arch *Archiver) SaveFile(node *Node) error {
|
||||||
arch.bl.Insert(blob)
|
arch.bl.Insert(blob)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arch *Archiver) loadTree(dir string) (*Tree, error) {
|
func (arch *Archiver) loadTree(dir string) (*Tree, error) {
|
||||||
|
|
2
key.go
2
key.go
|
@ -374,7 +374,7 @@ func (k *Key) Encrypt(ciphertext, plaintext []byte) (int, error) {
|
||||||
// IV || Ciphertext || HMAC.
|
// IV || Ciphertext || HMAC.
|
||||||
func (k *Key) decrypt(ks *keys, ciphertext []byte) ([]byte, error) {
|
func (k *Key) decrypt(ks *keys, ciphertext []byte) ([]byte, error) {
|
||||||
// check for plausible length
|
// check for plausible length
|
||||||
if len(ciphertext) <= ivSize+hmacSize {
|
if len(ciphertext) < ivSize+hmacSize {
|
||||||
panic("trying to decryipt invalid data: ciphertext too small")
|
panic("trying to decryipt invalid data: ciphertext too small")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue