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

Unified Diff: client/cmd/isolate/upload_tracker.go

Issue 2992113002: isolate: test uploading of individual regular files (Closed)
Patch Set: (revert accidental patchset 3) Created 3 years, 5 months 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 | « client/cmd/isolate/exp_archive.go ('k') | client/cmd/isolate/upload_tracker_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/isolate/upload_tracker.go
diff --git a/client/cmd/isolate/upload_tracker.go b/client/cmd/isolate/upload_tracker.go
index 44f00c89fd8d9397e85f9fdb9bfd7ee673918dff..ef098c287ff9bdd7a950ab32b7546b0ab6a4b179 100644
--- a/client/cmd/isolate/upload_tracker.go
+++ b/client/cmd/isolate/upload_tracker.go
@@ -32,6 +32,11 @@ import (
// limitedOS contains a subset of the functions from the os package.
type limitedOS interface {
Readlink(string) (string, error)
+
+ // Open is like os.Open, but returns an io.ReadCloser since
+ // that's all we need and it's easier to implment with a fake.
+ Open(string) (io.ReadCloser, error)
+
openFiler
}
@@ -48,6 +53,10 @@ func (sos standardOS) Readlink(name string) (string, error) {
return os.Readlink(name)
}
+func (sos standardOS) Open(name string) (io.ReadCloser, error) {
+ return os.Open(name)
+}
+
func (sos standardOS) OpenFile(name string, flag int, perm os.FileMode) (io.WriteCloser, error) {
return os.OpenFile(name, flag, perm)
}
@@ -151,7 +160,7 @@ func (ut *UploadTracker) tarAndUploadFiles(smallFiles []*Item) error {
func (ut *UploadTracker) uploadFiles(files []*Item) error {
// Handle the large individually-uploaded files.
for _, item := range files {
- d, err := hashFile(item.Path)
+ d, err := ut.hashFile(item.Path)
if err != nil {
return err
}
@@ -208,6 +217,15 @@ func (ut *UploadTracker) Finalize(isolatedPath string) (IsolatedSummary, error)
}, nil
}
+func (ut *UploadTracker) hashFile(path string) (isolated.HexDigest, error) {
+ f, err := ut.lOS.Open(path)
+ if err != nil {
+ return "", err
+ }
+ defer f.Close()
+ return isolated.Hash(f)
+}
+
// isolatedFile is an isolated file which is stored in memory.
// It can produce a corresponding Item, for upload to the server,
// and also write its contents to the filesystem.
« no previous file with comments | « client/cmd/isolate/exp_archive.go ('k') | client/cmd/isolate/upload_tracker_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698