@@ -28,19 +28,19 @@ func Extract(job *Job) {
2828 start := time .Now ()
2929
3030 for folder , files := range archives {
31- for _ , archiveName := range files {
31+ for _ , archive := range files {
3232 count ++
33- log .Printf ("==> Extracting Archive (%d/%d): %s" , count , total , archiveName )
33+ log .Printf ("==> Extracting Archive (%d/%d): %s" , count , total , archive )
3434
35- fSize , files , duration , err := job .processArchive (folder , archiveName )
35+ output , fSize , files , duration , err := job .processArchive (folder , archive )
3636 if err != nil {
3737 log .Printf ("[ERROR] Extracting: %v" , err )
3838 } else {
39- log .Printf ("==> Extracted Archive %s in %v: bytes: %d, files: %d" ,
40- archiveName , duration .Round (time .Millisecond ), fSize , len (files ))
39+ log .Printf ("==> Extracted Archive %s to %s in %v: bytes: %d, files: %d" ,
40+ archive , output , duration .Round (time .Millisecond ), fSize , len (files ))
4141 }
4242
43- if len (files ) > 0 {
43+ if len (files ) > 0 && job . Verbose {
4444 log .Printf ("==> Files:\n - %s" , strings .Join (files , "\n - " ))
4545 }
4646
@@ -49,13 +49,13 @@ func Extract(job *Job) {
4949 }
5050 }
5151
52- log .Printf ("==> Done.\n ==> Extracted %d archives; wrote %d files totalling %d bytes in %v" ,
53- total , fCount , size , time .Since (start ).Round (time .Millisecond ))
52+ log .Printf ("==> Done.\n ==> Extracted %d archives; wrote %d bytes into %d files in %v" ,
53+ total , size , fCount , time .Since (start ).Round (time .Millisecond ))
5454}
5555
56- func (j * Job ) processArchive (folder , archiveName string ) (int64 , []string , time.Duration , error ) {
56+ func (j * Job ) processArchive (folder , archive string ) (string , int64 , []string , time.Duration , error ) {
5757 file := & xtractr.XFile {
58- FilePath : archiveName , // Path to archive being extracted.
58+ FilePath : archive , // Path to archive being extracted.
5959 OutputDir : j .Output , // Folder to extract archive into.
6060 FileMode : j .FileMode .Mode (), // Write files with this mode.
6161 DirMode : j .DirMode .Mode (), // Write folders with this mode.
@@ -69,17 +69,17 @@ func (j *Job) processArchive(folder, archiveName string) (int64, []string, time.
6969 // Remove input path prefix from fileName,
7070 // append fileName.Dir to job.Output,
7171 // extract file into job.Output/file(sub)Folder(s).
72- file .OutputDir = filepath .Join (j .Output , filepath .Dir (strings .TrimPrefix (folder , archiveName )))
72+ file .OutputDir = filepath .Join (j .Output , filepath .Dir (strings .TrimPrefix (archive , folder )))
7373 }
7474
7575 start := time .Now ()
7676
7777 size , files , _ , err := xtractr .ExtractFile (file )
7878 if err != nil {
79- return size , files , time . Since ( start ), fmt .Errorf ("archive: %s: %w" , archiveName , err )
79+ err = fmt .Errorf ("archive: %s: %w" , archive , err )
8080 }
8181
82- return size , files , time .Since (start ), nil
82+ return file . OutputDir , size , files , time .Since (start ), err
8383}
8484
8585func (j * Job ) getArchives () xtractr.ArchiveList {
@@ -102,13 +102,14 @@ func (j *Job) getArchives() xtractr.ArchiveList {
102102 exclude = xtractr .AllExcept (j .Include ... )
103103 }
104104
105- for folder , fileList := range xtractr .FindCompressedFiles (xtractr.Filter {
105+ for _ , fileList := range xtractr .FindCompressedFiles (xtractr.Filter {
106106 Path : fileName ,
107107 ExcludeSuffix : exclude ,
108108 MaxDepth : int (j .MaxDepth ),
109109 MinDepth : int (j .MinDepth ),
110110 }) {
111- archives [folder ] = fileList
111+ // Group archive lists by the parent search folder that found them.
112+ archives [fileName ] = append (archives [fileName ], fileList ... )
112113 }
113114 }
114115
0 commit comments