(ctx context.Context, rep repo.Repository)
| 250 | } |
| 251 | |
| 252 | func (c *commandRestore) restoreOutput(ctx context.Context, rep repo.Repository) (restore.Output, error) { |
| 253 | err := c.constructTargetPairs(rep) |
| 254 | if err != nil { |
| 255 | return nil, err |
| 256 | } |
| 257 | |
| 258 | targetpath := c.restores[0].target |
| 259 | |
| 260 | m := c.detectRestoreMode(ctx, c.restoreMode, targetpath) |
| 261 | switch m { |
| 262 | case restoreModeLocal: |
| 263 | o := &restore.FilesystemOutput{ |
| 264 | TargetPath: targetpath, |
| 265 | OverwriteDirectories: c.restoreOverwriteDirectories, |
| 266 | OverwriteFiles: c.restoreOverwriteFiles, |
| 267 | OverwriteSymlinks: c.restoreOverwriteSymlinks, |
| 268 | IgnorePermissionErrors: c.restoreIgnorePermissionErrors, |
| 269 | WriteFilesAtomically: c.restoreWriteFilesAtomically, |
| 270 | SkipOwners: c.restoreSkipOwners, |
| 271 | SkipPermissions: c.restoreSkipPermissions, |
| 272 | SkipTimes: c.restoreSkipTimes, |
| 273 | WriteSparseFiles: c.restoreWriteSparseFiles, |
| 274 | FlushFiles: c.flushFiles, |
| 275 | } |
| 276 | |
| 277 | if err := o.Init(ctx); err != nil { |
| 278 | return nil, errors.Wrap(err, "unable to create output file") |
| 279 | } |
| 280 | |
| 281 | return o, nil |
| 282 | |
| 283 | case restoreModeZip, restoreModeZipNoCompress: |
| 284 | f, err := os.Create(targetpath) //nolint:gosec |
| 285 | if err != nil { |
| 286 | return nil, errors.Wrap(err, "unable to create output file") |
| 287 | } |
| 288 | |
| 289 | method := zip.Deflate |
| 290 | if m == restoreModeZipNoCompress { |
| 291 | method = zip.Store |
| 292 | } |
| 293 | |
| 294 | return restore.NewZipOutput(f, method), nil |
| 295 | |
| 296 | case restoreModeTar: |
| 297 | f, err := os.Create(targetpath) //nolint:gosec |
| 298 | if err != nil { |
| 299 | return nil, errors.Wrap(err, "unable to create output file") |
| 300 | } |
| 301 | |
| 302 | return restore.NewTarOutput(f), nil |
| 303 | |
| 304 | case restoreModeTgz: |
| 305 | f, err := os.Create(targetpath) //nolint:gosec |
| 306 | if err != nil { |
| 307 | return nil, errors.Wrap(err, "unable to create output file") |
| 308 | } |
| 309 |
no test coverage detected