11407: keepclient checks for ARVADOS_DEBUG and enables debugging.
[arvados.git] / sdk / go / keepclient / keepclient.go
index 79a87156a6cd829a87cd77a2ba357ce1484a4cdc..4f84afca61a413796fbb222eb5108473c449cfaf 100644 (file)
@@ -72,6 +72,7 @@ type KeepClient struct {
        lock               sync.RWMutex
        Client             *http.Client
        Retries            int
+       BlockCache         *BlockCache
 
        // set to 1 if all writable services are of disk type, otherwise 0
        replicasPerService int
@@ -167,6 +168,10 @@ func (kc *KeepClient) PutR(r io.Reader) (locator string, replicas int, err error
 }
 
 func (kc *KeepClient) getOrHead(method string, locator string) (io.ReadCloser, int64, string, error) {
+       if strings.HasPrefix(locator, "d41d8cd98f00b204e9800998ecf8427e+0") {
+               return ioutil.NopCloser(bytes.NewReader(nil)), 0, "", nil
+       }
+
        var errs []string
 
        tries_remaining := 1 + kc.Retries
@@ -402,6 +407,14 @@ func (kc *KeepClient) getSortedRoots(locator string) []string {
        return found
 }
 
+func (kc *KeepClient) cache() *BlockCache {
+       if kc.BlockCache != nil {
+               return kc.BlockCache
+       } else {
+               return DefaultBlockCache
+       }
+}
+
 type Locator struct {
        Hash  string
        Size  int      // -1 if data size is not known