From a8ce2e45cc2534052304088e394fb8f94f3b9afa Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 12 Jun 2025 22:17:57 +0200 Subject: [PATCH] backup: do not crash if nodeFromFileInfo fails this could crash in two cases: - if a directory is deleted between restic stating it and trying to list its directory content. - when restic tries to list the parent directory of a backup target, but the parent directory has been deleted. return an error in this case instead. --- internal/archiver/archiver.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/archiver/archiver.go b/internal/archiver/archiver.go index 4a6577d27..e509f9f85 100644 --- a/internal/archiver/archiver.go +++ b/internal/archiver/archiver.go @@ -264,6 +264,11 @@ func (arch *Archiver) trackItem(item string, previous, current *restic.Node, s I // nodeFromFileInfo returns the restic node from an os.FileInfo. func (arch *Archiver) nodeFromFileInfo(snPath, filename string, meta ToNoder, ignoreXattrListError bool) (*restic.Node, error) { node, err := meta.ToNode(ignoreXattrListError) + // node does not exist. This prevents all further processing for this file. + // If an error and a node are returned, then preserve as much data as possible (see below). + if err != nil && node == nil { + return nil, err + } if !arch.WithAtime { node.AccessTime = node.ModTime }