projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
12483: Remove dead code, update tests.
[arvados.git]
/
sdk
/
go
/
keepclient
/
keepclient.go
diff --git
a/sdk/go/keepclient/keepclient.go
b/sdk/go/keepclient/keepclient.go
index 029c6ee7f3a5834a8af149b64917aff2d5dc4bcb..4bc0fc5996368175c905b267aed26a2265a58003 100644
(file)
--- a/
sdk/go/keepclient/keepclient.go
+++ b/
sdk/go/keepclient/keepclient.go
@@
-1,3
+1,7
@@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
/* Provides low-level Get/Put primitives for accessing Arvados Keep blocks. */
package keepclient
/* Provides low-level Get/Put primitives for accessing Arvados Keep blocks. */
package keepclient
@@
-242,6
+246,10
@@
func (kc *KeepClient) getOrHead(method string, locator string) (io.ReadCloser, i
} else if resp.StatusCode == 404 {
count404++
}
} else if resp.StatusCode == 404 {
count404++
}
+ } else if resp.ContentLength < 0 {
+ // Missing Content-Length
+ resp.Body.Close()
+ return nil, 0, "", fmt.Errorf("Missing Content-Length of block")
} else {
// Success.
if method == "GET" {
} else {
// Success.
if method == "GET" {
@@
-284,6
+292,12
@@
func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error)
return kc.getOrHead("GET", locator)
}
return kc.getOrHead("GET", locator)
}
+// ReadAt() retrieves a portion of block from the cache if it's
+// present, otherwise from the network.
+func (kc *KeepClient) ReadAt(locator string, p []byte, off int) (int, error) {
+ return kc.cache().ReadAt(kc, locator, p, off)
+}
+
// Ask() verifies that a block with the given hash is available and
// readable, according to at least one Keep service. Unlike Get, it
// does not retrieve the data or verify that the data content matches
// Ask() verifies that a block with the given hash is available and
// readable, according to at least one Keep service. Unlike Get, it
// does not retrieve the data or verify that the data content matches
@@
-430,6
+444,10
@@
func (kc *KeepClient) cache() *BlockCache {
}
}
}
}
+func (kc *KeepClient) ClearBlockCache() {
+ kc.cache().Clear()
+}
+
var (
// There are four global http.Client objects for the four
// possible permutations of TLS behavior (verify/skip-verify)
var (
// There are four global http.Client objects for the four
// possible permutations of TLS behavior (verify/skip-verify)