mirror of
https://github.com/gen2brain/cbconvert
synced 2025-10-14 02:28:51 +02:00
add progressbar for cover
This commit is contained in:
22
cbconvert.go
22
cbconvert.go
@@ -105,6 +105,7 @@ var (
|
|||||||
workdir string
|
workdir string
|
||||||
nfiles int
|
nfiles int
|
||||||
current int
|
current int
|
||||||
|
bar *pb.ProgressBar
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -219,7 +220,6 @@ func convertDocument(file string) {
|
|||||||
|
|
||||||
npages := doc.Pages()
|
npages := doc.Pages()
|
||||||
|
|
||||||
var bar *pb.ProgressBar
|
|
||||||
if !opts.Quiet {
|
if !opts.Quiet {
|
||||||
bar = pb.New(npages)
|
bar = pb.New(npages)
|
||||||
bar.ShowTimeLeft = false
|
bar.ShowTimeLeft = false
|
||||||
@@ -260,7 +260,6 @@ func convertArchive(file string) {
|
|||||||
}
|
}
|
||||||
defer archive.Close()
|
defer archive.Close()
|
||||||
|
|
||||||
var bar *pb.ProgressBar
|
|
||||||
if !opts.Quiet {
|
if !opts.Quiet {
|
||||||
bar = pb.New(ncontents)
|
bar = pb.New(ncontents)
|
||||||
bar.ShowTimeLeft = false
|
bar.ShowTimeLeft = false
|
||||||
@@ -334,7 +333,6 @@ func convertDirectory(path string) {
|
|||||||
|
|
||||||
images := getImages(path)
|
images := getImages(path)
|
||||||
|
|
||||||
var bar *pb.ProgressBar
|
|
||||||
if !opts.Quiet {
|
if !opts.Quiet {
|
||||||
bar = pb.New(nfiles)
|
bar = pb.New(nfiles)
|
||||||
bar.ShowTimeLeft = false
|
bar.ShowTimeLeft = false
|
||||||
@@ -392,7 +390,6 @@ func saveArchive(file string) {
|
|||||||
z := zip.NewWriter(zipfile)
|
z := zip.NewWriter(zipfile)
|
||||||
files, _ := ioutil.ReadDir(workdir)
|
files, _ := ioutil.ReadDir(workdir)
|
||||||
|
|
||||||
var bar *pb.ProgressBar
|
|
||||||
if !opts.Quiet {
|
if !opts.Quiet {
|
||||||
bar = pb.New(len(files))
|
bar = pb.New(len(files))
|
||||||
bar.ShowTimeLeft = false
|
bar.ShowTimeLeft = false
|
||||||
@@ -663,7 +660,7 @@ func getFiles() []string {
|
|||||||
for _, f := range fs {
|
for _, f := range fs {
|
||||||
if isArchive(f.Name()) || isArchive(f.Name()) {
|
if isArchive(f.Name()) || isArchive(f.Name()) {
|
||||||
if isSize(f.Size()) {
|
if isSize(f.Size()) {
|
||||||
files = append(files, f.Name())
|
files = append(files, filepath.Join(path, f.Name()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -983,6 +980,15 @@ func main() {
|
|||||||
|
|
||||||
files := getFiles()
|
files := getFiles()
|
||||||
nfiles = len(files)
|
nfiles = len(files)
|
||||||
|
|
||||||
|
if opts.Cover || opts.Thumbnail {
|
||||||
|
if !opts.Quiet {
|
||||||
|
bar = pb.New(nfiles)
|
||||||
|
bar.ShowTimeLeft = false
|
||||||
|
bar.Start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for n, file := range files {
|
for n, file := range files {
|
||||||
current = n + 1
|
current = n + 1
|
||||||
|
|
||||||
@@ -994,9 +1000,15 @@ func main() {
|
|||||||
|
|
||||||
if opts.Cover {
|
if opts.Cover {
|
||||||
extractCover(file, stat)
|
extractCover(file, stat)
|
||||||
|
if !opts.Quiet {
|
||||||
|
bar.Increment()
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
} else if opts.Thumbnail {
|
} else if opts.Thumbnail {
|
||||||
extractThumbnail(file, stat)
|
extractThumbnail(file, stat)
|
||||||
|
if !opts.Quiet {
|
||||||
|
bar.Increment()
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user