(ctx context.Context, srcFile string, dst string, cType CompressType, secret string)
| 1101 | } |
| 1102 | |
| 1103 | func (f FileOp) Decompress(ctx context.Context, srcFile string, dst string, cType CompressType, secret string) error { |
| 1104 | if cType == Tar || cType == Zip || cType == TarGz || cType == Rar || cType == X7z { |
| 1105 | shellArchiver, err := NewExtractShellArchiver(cType) |
| 1106 | if !f.Stat(dst) { |
| 1107 | _ = f.CreateDir(dst, 0755) |
| 1108 | } |
| 1109 | if err == nil { |
| 1110 | if err = shellArchiver.Extract(ctx, srcFile, dst, secret); err == nil { |
| 1111 | return nil |
| 1112 | } |
| 1113 | if cType == TarGz { |
| 1114 | if strings.Contains(err.Error(), "bad decrypt") { |
| 1115 | return buserr.New("ErrBadDecrypt") |
| 1116 | } |
| 1117 | if err := shellArchiver.Extract(ctx, srcFile, dst, "-"); strings.Contains(err.Error(), "bad decrypt") { |
| 1118 | return buserr.New("ErrBadDecrypt") |
| 1119 | } |
| 1120 | } |
| 1121 | } else { |
| 1122 | if cType == Rar || cType == X7z { |
| 1123 | return err |
| 1124 | } |
| 1125 | } |
| 1126 | } |
| 1127 | return f.decompressWithSDK(ctx, srcFile, dst, cType) |
| 1128 | } |
| 1129 | |
| 1130 | func ZipFile(ctx context.Context, files []archiver.File, dst afero.File, progress func(current, total int, message string)) error { |
| 1131 | zw := zip.NewWriter(dst) |
no test coverage detected