[amber] cleanup mutex handling in initSource()
The auto-watch is no longer started inside this method, so the unlock can be
simplified. The error return change is also per golint advice.
Test: CQ
Change-Id: I45027043801b5f8ac792b6c3a9726f60698666ff
diff --git a/go/src/amber/source/source.go b/go/src/amber/source/source.go
index 8e05888..2bd566f 100644
--- a/go/src/amber/source/source.go
+++ b/go/src/amber/source/source.go
@@ -278,10 +278,10 @@
// data to create the derived fields, like the TUFClient.
func (f *Source) initSource() error {
f.mu.Lock()
+ defer f.mu.Unlock()
keys, err := newTUFKeys(f.cfg.Config.RootKeys)
if err != nil {
- f.mu.Unlock()
return err
}
f.keys = keys
@@ -290,18 +290,11 @@
// it's own directory.
localStore, err := NewFileStore(filepath.Join(f.dir, "tuf.json"))
if err != nil {
- f.mu.Unlock()
return IOError{fmt.Errorf("couldn't open datastore: %s", err)}
}
f.localStore = localStore
- if err := f.updateTUFClientLocked(); err != nil {
- f.mu.Unlock()
- return err
- }
- f.mu.Unlock()
-
- return nil
+ return f.updateTUFClientLocked()
}
// Start starts background operations associated with this Source, such as