7241: Add AzureBlobVolume
[arvados.git] / services / keepstore / volume_unix.go
index f4b49710e9192deabb2119d72ccbb389edcbe7bc..6c0f5c4e978d995b5c9308f52d5d2414045d64fc 100644 (file)
@@ -122,6 +122,13 @@ func (v *UnixVolume) Compare(loc string, expect []byte) error {
        bufLen := 1 << 20
        if int64(bufLen) > stat.Size() {
                bufLen = int(stat.Size())
+               if bufLen < 1 {
+                       // len(buf)==0 would prevent us from handling
+                       // empty files the same way as non-empty
+                       // files, because reading 0 bytes at a time
+                       // never reaches EOF.
+                       bufLen = 1
+               }
        }
        cmp := expect
        buf := make([]byte, bufLen)
@@ -318,7 +325,7 @@ func (v *UnixVolume) Delete(loc string) error {
        }
        defer unlockfile(f)
 
-       // If the block has been PUT in the last blob_signature_ttl
+       // If the block has been PUT in the last blobSignatureTTL
        // seconds, return success without removing the block. This
        // protects data from garbage collection until it is no longer
        // possible for clients to retrieve the unreferenced blocks
@@ -326,7 +333,7 @@ func (v *UnixVolume) Delete(loc string) error {
        if fi, err := os.Stat(p); err != nil {
                return err
        } else {
-               if time.Since(fi.ModTime()) < blob_signature_ttl {
+               if time.Since(fi.ModTime()) < blobSignatureTTL {
                        return nil
                }
        }