Skip to content

Commit

Permalink
Fix GZip & File/progress
Browse files Browse the repository at this point in the history
Package Archive/GZIP
- remove call of getGunzipSize
- expose to public the internal getGunZipSize => GetGunZipSize

Package file/progress
- fix nil function with progress, use empty function if function are nil
  • Loading branch information
nabbar committed Oct 16, 2023
1 parent 4675b42 commit b07fafb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 1 addition & 8 deletions archive/gzip/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,10 @@ import (
)

func GetFile(src io.ReadSeeker, dst io.WriteSeeker) errors.Error {
var siz = getGunZipSize(src)

if d, k := dst.(libfpg.Progress); k && siz > 0 {
d.Reset(siz)
}

if _, e := src.Seek(0, io.SeekStart); e != nil {
return ErrorFileSeek.Error(e)
} else if _, e = dst.Seek(0, io.SeekStart); e != nil {
return ErrorFileSeek.Error(e)
} else if siz > 0 {
}

r, e := gz.NewReader(src)
Expand All @@ -68,7 +61,7 @@ func GetFile(src io.ReadSeeker, dst io.WriteSeeker) errors.Error {
}
}

func getGunZipSize(src io.ReadSeeker) int64 {
func GetGunZipSize(src io.ReadSeeker) int64 {
if _, e := src.Seek(0, io.SeekStart); e != nil {
return 0
}
Expand Down
12 changes: 12 additions & 0 deletions file/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,26 @@ import (
)

func (o *progress) RegisterFctIncrement(fct FctIncrement) {
if fct == nil {
fct = func(size int64) {}
}

o.fi.Store(fct)
}

func (o *progress) RegisterFctReset(fct FctReset) {
if fct == nil {
fct = func(size, current int64) {}
}

o.fr.Store(fct)
}

func (o *progress) RegisterFctEOF(fct FctEOF) {
if fct == nil {
fct = func() {}
}

o.fe.Store(fct)
}

Expand Down

0 comments on commit b07fafb

Please sign in to comment.