Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9071)

Unified Diff: cipd/client/cipd/common/common.go

Issue 2501023002: Add FileEntry cache to TagCache for selfupdate. (Closed)
Patch Set: fix comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cipd/client/cipd/internal/messages/messages.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cipd/client/cipd/common/common.go
diff --git a/cipd/client/cipd/common/common.go b/cipd/client/cipd/common/common.go
index 9b77b5a8407bc9183b6e9ede27cc6a5db3c424df..91089274d34f49bbf6459bf7bd63ece0e15fc183 100644
--- a/cipd/client/cipd/common/common.go
+++ b/cipd/client/cipd/common/common.go
@@ -54,6 +54,20 @@ func ValidateInstanceID(s string) error {
return nil
}
+// ValidateFileHash returns error if a string isn't a valid exe hash.
+func ValidateFileHash(s string) error {
+ // file hashes are SHA1 hex digests currently.
+ if len(s) != 40 {
+ return fmt.Errorf("not a valid exe hash %q: not 40 bytes", s)
+ }
+ for _, c := range s {
+ if !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
+ return fmt.Errorf("not a valid exe hash %q: wrong char %c", s, c)
+ }
+ }
+ return nil
+}
+
// ValidatePin returns error if package name or instance id are invalid.
func ValidatePin(pin Pin) error {
if err := ValidatePackageName(pin.PackageName); err != nil {
« no previous file with comments | « no previous file | cipd/client/cipd/internal/messages/messages.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698