Commit 3d437fa2 authored by Michael Schurter's avatar Michael Schurter
Browse files

Handle errors during snapshotting

If an alloc dir is being GC'd (removed) during snapshotting the walk
func will be passed an error. Previously we didn't check for an error so
a panic would occur when we'd try to use a nil `fileInfo`.
parent 0cdc12bb
Branches unavailable
No related merge requests found
Showing with 5 additions and 1 deletion
+5 -1
......@@ -139,6 +139,10 @@ func (d *AllocDir) Snapshot(w io.Writer) error {
defer tw.Close()
walkFn := func(path string, fileInfo os.FileInfo, err error) error {
if err != nil {
return err
}
// Include the path of the file name relative to the alloc dir
// so that we can put the files in the right directories
relPath, err := filepath.Rel(d.AllocDir, path)
......@@ -182,7 +186,7 @@ func (d *AllocDir) Snapshot(w io.Writer) error {
// directories in the archive
for _, path := range rootPaths {
if err := filepath.Walk(path, walkFn); err != nil {
return err
return fmt.Errorf("failed to snapshot %s: %v", path, err)
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment