@@ -284,12 +284,10 @@ func copyLocal(dst, src, ext string, decompress bool, description string, expect
284
284
if err != nil {
285
285
return err
286
286
}
287
- if description != "" {
288
- // TODO: progress bar for copy
289
- }
290
287
if _ , ok := Decompressor (ext ); ok && decompress {
291
- return decompressLocal (dstPath , srcPath , ext )
288
+ return decompressLocal (dstPath , srcPath , ext , description )
292
289
}
290
+ // TODO: progress bar for copy
293
291
return fs .CopyFile (dstPath , srcPath )
294
292
}
295
293
@@ -311,12 +309,22 @@ func Decompressor(ext string) ([]string, bool) {
311
309
return []string {program , "-d" }, true
312
310
}
313
311
314
- func decompressLocal (dst , src , ext string ) error {
312
+ func decompressLocal (dst , src , ext string , description string ) error {
315
313
command , found := Decompressor (ext )
316
314
if ! found {
317
315
return fmt .Errorf ("decompressLocal: unknown extension %s" , ext )
318
316
}
319
317
logrus .Infof ("decompressing %s with %v" , ext , command )
318
+
319
+ st , err := os .Stat (src )
320
+ if err != nil {
321
+ return err
322
+ }
323
+ bar , err := createBar (st .Size ())
324
+ if err != nil {
325
+ return err
326
+ }
327
+
320
328
in , err := os .Open (src )
321
329
if err != nil {
322
330
return err
@@ -329,15 +337,23 @@ func decompressLocal(dst, src, ext string) error {
329
337
defer out .Close ()
330
338
buf := new (bytes.Buffer )
331
339
cmd := exec .Command (command [0 ], command [1 :]... )
332
- cmd .Stdin = in
340
+ cmd .Stdin = bar . NewProxyReader ( in )
333
341
cmd .Stdout = out
334
342
cmd .Stderr = buf
343
+ if ! HideProgress {
344
+ if description == "" {
345
+ description = filepath .Base (src )
346
+ }
347
+ fmt .Printf ("Decompressing %s\n " , description )
348
+ }
349
+ bar .Start ()
335
350
err = cmd .Run ()
336
351
if err != nil {
337
352
if ee , ok := err .(* exec.ExitError ); ok {
338
353
ee .Stderr = buf .Bytes ()
339
354
}
340
355
}
356
+ bar .Finish ()
341
357
return err
342
358
}
343
359
0 commit comments