X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7ce745d5645dc49c2833c1c617fd488bf3a62307..b085f051e459981a385c95c4ae147546312c08d9:/services/api/app/models/blob.rb diff --git a/services/api/app/models/blob.rb b/services/api/app/models/blob.rb index 5decd77261..799279d040 100644 --- a/services/api/app/models/blob.rb +++ b/services/api/app/models/blob.rb @@ -1,4 +1,13 @@ class Blob + extend DbCurrentTime + + def initialize locator + @locator = locator + end + + def empty? + !!@locator.match(/^d41d8cd98f00b204e9800998ecf8427e(\+.*)?$/) + end # In order to get a Blob from Keep, you have to prove either # [a] you have recently written it to Keep yourself, or @@ -35,7 +44,7 @@ class Blob end timestamp = opts[:expire] else - timestamp = Time.now.to_i + (opts[:ttl] || 600) + timestamp = db_current_time.to_i + (opts[:ttl] || 1209600) end timestamp_hex = timestamp.to_s(16) # => "53163cb4" @@ -82,7 +91,7 @@ class Blob if !timestamp.match /^[\da-f]+$/ raise Blob::InvalidSignatureError.new 'Timestamp is not a base16 number.' end - if timestamp.to_i(16) < Time.now.to_i + if timestamp.to_i(16) < db_current_time.to_i raise Blob::InvalidSignatureError.new 'Signature expiry time has passed.' end