mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 06:07:44 +00:00
Correctly deal with empty files
This commit is contained in:
parent
6d56d7d4c6
commit
c0b3021494
10
archiver.go
10
archiver.go
@ -167,13 +167,13 @@ func (arch *Archiver) SaveFile(node *Node) error {
|
||||
buf := GetChunkBuf("blob single file")
|
||||
defer FreeChunkBuf("blob single file", buf)
|
||||
n, err := io.ReadFull(file, buf)
|
||||
if err != nil && err != io.ErrUnexpectedEOF {
|
||||
return err
|
||||
if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
|
||||
return arrar.Annotate(err, "SaveFile() read small file")
|
||||
}
|
||||
|
||||
blob, err := arch.ch.Save(backend.Data, buf[:n])
|
||||
if err != nil {
|
||||
return err
|
||||
return arrar.Annotate(err, "SaveFile() save chunk")
|
||||
}
|
||||
|
||||
arch.update(arch.SaveStats, Stats{Bytes: blob.Size})
|
||||
@ -195,7 +195,7 @@ func (arch *Archiver) SaveFile(node *Node) error {
|
||||
|
||||
if err != nil {
|
||||
FreeChunkBuf("blob chunker", buf)
|
||||
return err
|
||||
return arrar.Annotate(err, "SaveFile() chunker.Next()")
|
||||
}
|
||||
|
||||
// acquire token, start goroutine to save chunk
|
||||
@ -231,7 +231,7 @@ func (arch *Archiver) SaveFile(node *Node) error {
|
||||
arch.bl.Insert(blob)
|
||||
}
|
||||
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
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.
|
||||
func (k *Key) decrypt(ks *keys, ciphertext []byte) ([]byte, error) {
|
||||
// check for plausible length
|
||||
if len(ciphertext) <= ivSize+hmacSize {
|
||||
if len(ciphertext) < ivSize+hmacSize {
|
||||
panic("trying to decryipt invalid data: ciphertext too small")
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user