You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Or something like this - we already call os.Stat() to check for existence - so this adds the size check and then the comparison, currently byte-by-byte. It would be more memory-efficient (not necessarily faster) if we compare hashes - dynamically calculated, or perhaps statically embedded in the Go binary and statically written in the cache directory. Given the files add up to ~20MB we'd probably want hashes.
// fileChanged checks if a file's content differs from the provided bytes.funcfileChanged(filenamestring, content []byte) (bool, error) {
stat, err:=os.Stat(filename)
iferr!=nil {
ifos.IsNotExist(err) {
returntrue, nil
}
returnfalse, fmt.Errorf("could not stat file: %w", err)
}
ifint(stat.Size()) !=len(content) {
returntrue, nil
}
current, err:=os.ReadFile(filename)
iferr!=nil {
returnfalse, err
}
return!bytes.Equal(current, content), nil
}
When running the Legacy CLI and there is a non-zero exit code, we should check file hashes and permissions and if needed cleanup the cache directory.
Tasks
The text was updated successfully, but these errors were encountered: