Skip to content

Commit

Permalink
Handle symlink on unarchiving phase
Browse files Browse the repository at this point in the history
  • Loading branch information
premist committed Jan 7, 2022
1 parent 15a063a commit 7776bc4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cacher/cacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,19 @@ func (c *Cacher) Restore(ctx context.Context, i *RestoreRequest) (retErr error)
if err := os.MkdirAll(target, 0755); err != nil {
return fmt.Errorf("failed to make directory %s: %w", target, err)
}
case tar.TypeSymlink:
c.log("creating symlink %s", target)

// Create the parent directory in case it does not exist...
parent := filepath.Dir(target)
if err := os.MkdirAll(parent, 0755); err != nil {
return fmt.Errorf("failed to make parent directory %s: %w", parent, err)
}

c.log("symlink %s to disk", target)
if err := os.Symlink(header.Linkname, target); err != nil {
return fmt.Errorf("failed to symlink %s: %w", target, err)
}
case tar.TypeReg:
c.log("creating file %s", target)

Expand Down

0 comments on commit 7776bc4

Please sign in to comment.