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)
}
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
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
}
}