forked from TrueCloudLab/restic
Add missing return to fix failing test
This commit is contained in:
parent
7a48c9ebd7
commit
2101dfe448
1 changed files with 17 additions and 14 deletions
|
@ -88,16 +88,13 @@ func (node Node) restoreExtendedAttributes(path string) (err error) {
|
||||||
// fill extended attributes in the node. This also includes the Generic attributes for windows.
|
// fill extended attributes in the node. This also includes the Generic attributes for windows.
|
||||||
func (node *Node) fillExtendedAttributes(path string, _ bool) (err error) {
|
func (node *Node) fillExtendedAttributes(path string, _ bool) (err error) {
|
||||||
var fileHandle windows.Handle
|
var fileHandle windows.Handle
|
||||||
fileHandle, err = getFileHandleForEA(node.Type, path)
|
if fileHandle, err = getFileHandleForEA(node.Type, path); fileHandle == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("get EA failed while opening file handle for path %v, with: %v", path, err)
|
return errors.Errorf("get EA failed while opening file handle for path %v, with: %v", path, err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer closeFileHandle(fileHandle, path) // Replaced inline defer with named function call
|
||||||
err := windows.CloseHandle(fileHandle)
|
|
||||||
if err != nil {
|
|
||||||
debug.Log("Error closing file handle for %s: %v\n", path, err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
//Get the windows Extended Attributes using the file handle
|
//Get the windows Extended Attributes using the file handle
|
||||||
var extAtts []fs.ExtendedAttribute
|
var extAtts []fs.ExtendedAttribute
|
||||||
extAtts, err = fs.GetFileEA(fileHandle)
|
extAtts, err = fs.GetFileEA(fileHandle)
|
||||||
|
@ -138,20 +135,26 @@ func getFileHandleForEA(nodeType, path string) (handle windows.Handle, err error
|
||||||
return handle, err
|
return handle, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// restoreExtendedAttributes handles restore of the Windows Extended Attributes to the specified path.
|
// closeFileHandle safely closes a file handle and logs any errors.
|
||||||
// The Windows API requires setting of all the Extended Attributes in one call.
|
func closeFileHandle(fileHandle windows.Handle, path string) {
|
||||||
func restoreExtendedAttributes(nodeType, path string, eas []fs.ExtendedAttribute) (err error) {
|
|
||||||
var fileHandle windows.Handle
|
|
||||||
fileHandle, err = getFileHandleForEA(nodeType, path)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Errorf("set EA failed while opening file handle for path %v, with: %v", path, err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
err := windows.CloseHandle(fileHandle)
|
err := windows.CloseHandle(fileHandle)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
debug.Log("Error closing file handle for %s: %v\n", path, err)
|
debug.Log("Error closing file handle for %s: %v\n", path, err)
|
||||||
}
|
}
|
||||||
}()
|
}
|
||||||
|
|
||||||
|
// restoreExtendedAttributes handles restore of the Windows Extended Attributes to the specified path.
|
||||||
|
// The Windows API requires setting of all the Extended Attributes in one call.
|
||||||
|
func restoreExtendedAttributes(nodeType, path string, eas []fs.ExtendedAttribute) (err error) {
|
||||||
|
var fileHandle windows.Handle
|
||||||
|
if fileHandle, err = getFileHandleForEA(nodeType, path); fileHandle == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return errors.Errorf("set EA failed while opening file handle for path %v, with: %v", path, err)
|
||||||
|
}
|
||||||
|
defer closeFileHandle(fileHandle, path) // Replaced inline defer with named function call
|
||||||
|
|
||||||
if err = fs.SetFileEA(fileHandle, eas); err != nil {
|
if err = fs.SetFileEA(fileHandle, eas); err != nil {
|
||||||
return errors.Errorf("set EA failed for path %v, with: %v", path, err)
|
return errors.Errorf("set EA failed for path %v, with: %v", path, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue