(info *plugin.PreInstallPackageItem, targetPath string)
| 276 | } |
| 277 | |
| 278 | func (b *impl) moveRemoteFile(info *plugin.PreInstallPackageItem, targetPath string) error { |
| 279 | u, err := url.Parse(info.Path) |
| 280 | label := info.Label() |
| 281 | if err != nil { |
| 282 | return err |
| 283 | } |
| 284 | filePath, err := b.Download(u, info.Headers) |
| 285 | if err != nil { |
| 286 | return fmt.Errorf("failed to download %s file, err:%w", label, err) |
| 287 | } |
| 288 | defer func() { |
| 289 | // del cache file |
| 290 | _ = os.Remove(filePath) |
| 291 | }() |
| 292 | checksum := info.Checksum() |
| 293 | pterm.Printf("Verifying checksum %s...\n", checksum.Value) |
| 294 | verify := checksum.Verify(filePath) |
| 295 | if !verify { |
| 296 | fmt.Printf("Checksum error, file: %s\n", filePath) |
| 297 | return errors.New("checksum error") |
| 298 | } |
| 299 | decompressor := util.NewDecompressor(filePath) |
| 300 | if decompressor == nil { |
| 301 | // If it is not a compressed file, move file to the corresponding sdk directory, |
| 302 | // and the rest be handled by the PostInstall function. |
| 303 | if err = util.MoveFiles(filePath, targetPath); err != nil { |
| 304 | return fmt.Errorf("failed to move file, err:%w", err) |
| 305 | } |
| 306 | return nil |
| 307 | } |
| 308 | pterm.Printf("Unpacking %s...\n", filePath) |
| 309 | err = decompressor.Decompress(targetPath) |
| 310 | if err != nil { |
| 311 | return fmt.Errorf("unpack failed, err:%w", err) |
| 312 | } |
| 313 | return nil |
| 314 | } |
| 315 | |
| 316 | func (b *impl) runtimePathDirName(isMain bool, info *plugin.PreInstallPackageItem) string { |
| 317 | var name string |
no test coverage detected