Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not update corrupted files hash by default #28

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion check.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,17 @@ func checkFile(fn string) {
}
stats.outdated++
}

if !args.qq {
printComparison(stored, actual)
}
err = storeAttr(f, actual)

// Only update the stored attribute if it is not corrupted **OR**
// if argument 'corruptupdate' been given.
if stored.ts != actual.ts || args.corruptupdate {
err = storeAttr(f, actual)
}

if err != nil {
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
stats.errorsWritingXattr++
Expand Down
12 changes: 7 additions & 5 deletions cshatag.1
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ rewritten in Go in 2019.

.SH OPTIONS

-dry-run don't make any changes
-dry-run don't make any changes
.br
-recursive recursively process the contents of directories
-recursive recursively process the contents of directories
.br
-remove remove cshatag's xattrs from FILE
-remove remove cshatag's xattrs from FILE
.br
-q quiet mode - don't report <ok> files
-q quiet mode - don't report <ok> files
.br
-qq quiet2 mode - only report <corrupt> files and errors
-qq quiet2 mode - only report <corrupt> files and errors
.br
-corruptupdate For any corrupted files found update the stored CRC

.SH EXAMPLES

Expand Down
12 changes: 7 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ var stats struct {
}

var args struct {
remove bool
recursive bool
q bool
qq bool
dryrun bool
remove bool
recursive bool
q bool
qq bool
dryrun bool
corruptupdate bool
}

// walkFn is used when `cshatag` is called with the `--recursive` option. It is the function called
Expand Down Expand Up @@ -84,6 +85,7 @@ func main() {
flag.BoolVar(&args.recursive, "recursive", false, "Recursively descend into subdirectories. "+
"Symbolic links are not followed.")
flag.BoolVar(&args.dryrun, "dry-run", false, "don't make any changes")
flag.BoolVar(&args.corruptupdate, "corruptupdate", false, "For any corrupted files found update the stored CRC.")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "%s %s\n", myname, GitVersion)
fmt.Fprintf(os.Stderr, "Usage: %s [OPTIONS] FILE [FILE2 ...]\n", myname)
Expand Down
Loading