Skip to content

Commit

Permalink
fix err check #28
Browse files Browse the repository at this point in the history
  • Loading branch information
laktak committed Jan 9, 2025
1 parent 3a407a1 commit d1a221a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/chkbit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func (m *Main) run() int {

if cli.Quiet {
m.progress = Quiet
} else if fileInfo, _ := os.Stdout.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
} else if fileInfo, err := os.Stdout.Stat(); err == nil && (fileInfo.Mode()&os.ModeCharDevice) == 0 {
m.progress = Summary
} else if cli.Plain {
m.progress = Plain
Expand Down
16 changes: 11 additions & 5 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ func newIndex(context *Context, path string, files []string, dirList []string, r
}
}

func getMtime(path string) int64 {
info, _ := os.Stat(path)
return int64(info.ModTime().UnixNano() / 1e6)
func getMtime(path string) (int64, error) {
if info, err := os.Stat(path); err != nil {
return 0, err
} else {
return int64(info.ModTime().UnixNano() / 1e6), nil
}
}

func (i *Index) getIndexFilepath() string {
Expand Down Expand Up @@ -203,13 +206,16 @@ func (i *Index) checkFix(forceUpdateDmg bool) {
}

func (i *Index) mtimeChanged(name string, ii idxInfo) bool {
mtime := getMtime(filepath.Join(i.path, name))
mtime, _ := getMtime(filepath.Join(i.path, name))
return ii.ModTime != mtime
}

func (i *Index) calcFile(name string, a string) (*idxInfo, error) {
path := filepath.Join(i.path, name)
mtime := getMtime(path)
mtime, err := getMtime(path)
if err != nil {
return nil, err
}
h, err := Hashfile(path, a, i.context.perfMonBytes)
if err != nil {
return nil, err
Expand Down

0 comments on commit d1a221a

Please sign in to comment.