mirror of
https://github.com/restic/restic.git
synced 2025-10-09 12:12:39 +00:00
Add more error handling
This commit is contained in:
@@ -101,12 +101,23 @@ func (a *acl) decode(xattr []byte) {
|
||||
func (a *acl) encode() []byte {
|
||||
buf := new(bytes.Buffer)
|
||||
ae := new(aclElem)
|
||||
binary.Write(buf, binary.LittleEndian, &a.Version)
|
||||
|
||||
err := binary.Write(buf, binary.LittleEndian, &a.Version)
|
||||
// write to a bytes.Buffer always returns a nil error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, elem := range a.List {
|
||||
ae.Tag = uint16(elem.getType())
|
||||
ae.Perm = elem.Perm
|
||||
ae.ID = elem.getID()
|
||||
binary.Write(buf, binary.LittleEndian, ae)
|
||||
|
||||
err := binary.Write(buf, binary.LittleEndian, ae)
|
||||
// write to a bytes.Buffer always returns a nil error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
@@ -25,7 +25,8 @@ func writeDump(ctx context.Context, repo restic.Repository, tree *restic.Tree, r
|
||||
rootNode.Path = rootPath
|
||||
err := dumpTree(ctx, repo, rootNode, rootPath, dmp)
|
||||
if err != nil {
|
||||
dmp.Close()
|
||||
// ignore subsequent errors
|
||||
_ = dmp.Close()
|
||||
|
||||
return err
|
||||
}
|
||||
|
@@ -23,10 +23,16 @@ func readZipFile(f *zip.File) ([]byte, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rc.Close()
|
||||
|
||||
b := &bytes.Buffer{}
|
||||
_, err = b.ReadFrom(rc)
|
||||
if err != nil {
|
||||
// ignore subsequent errors
|
||||
_ = rc.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = rc.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user