Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor master head naming improvement

  • Loading branch information...
commit 9894d45f5407283ecb19871d8fd56cdc305413df 1 parent 6593374
Yurii Rashkovskii authored
Showing with 10 additions and 5 deletions.
  1. +10 −5 lib/strokedb/stores/file_storage.rb
15 lib/strokedb/stores/file_storage.rb
View
@@ -1,5 +1,10 @@
module StrokeDB
- RAW_HEAD_VERSION_UUID = Util.sha1_uuid("strokedb-internal:head-version").to_raw_uuid
+
+ def self.head(branch="master")
+ Util.sha1_uuid(branch).to_raw_uuid
+ end
+
+ RAW_MASTER_HEAD_VERSION_UUID = head()
class FileStorage < Storage
@@ -14,7 +19,7 @@ def save_as_head!(document, timestamp)
def find(uuid, version=nil, opts = {}, &block)
uuid_version = uuid + (version ? ".#{version}" : "")
- key = uuid.to_raw_uuid + (version ? version.to_raw_uuid : RAW_HEAD_VERSION_UUID)
+ key = uuid.to_raw_uuid + (version ? version.to_raw_uuid : RAW_MASTER_HEAD_VERSION_UUID)
if (ptr = @uindex.find(key)) && (ptr[0,20] != "\x00" * 20) # no way ptr will be zero
raw_doc = StrokeDB::deserialize(read_at_ptr(ptr[0,20]))
unless opts[:no_instantiation]
@@ -28,7 +33,7 @@ def find(uuid, version=nil, opts = {}, &block)
end
def include?(uuid,version=nil)
- key = uuid.to_raw_uuid + (version ? version.to_raw_uuid : RAW_HEAD_VERSION_UUID)
+ key = uuid.to_raw_uuid + (version ? version.to_raw_uuid : RAW_MASTER_HEAD_VERSION_UUID)
!@uindex.find(key).nil?
end
@@ -47,7 +52,7 @@ def each(options = {})
@uindex.each do |key, value|
timestamp = StrokeDB.deserialize(read_at_ptr(value[20,20]))
next if after && (timestamp <= after)
- if key[16,16] == RAW_HEAD_VERSION_UUID || include_versions
+ if key[16,16] == RAW_MASTER_HEAD_VERSION_UUID || include_versions
yield Document.from_raw(options[:store],StrokeDB.deserialize(read_at_ptr(value[0,20])))
end
end
@@ -59,7 +64,7 @@ def perform_save!(document, timestamp, options = {})
ts_ptr = DistributedPointer.pack(@archive.raw_uuid,ts_position)
ptr = DistributedPointer.pack(@archive.raw_uuid,position)
uuid = document.raw_uuid
- @uindex.insert(uuid + RAW_HEAD_VERSION_UUID, ptr + ts_ptr) if options[:head] || !document.is_a?(VersionedDocument)
+ @uindex.insert(uuid + RAW_MASTER_HEAD_VERSION_UUID, ptr + ts_ptr) if options[:head] || !document.is_a?(VersionedDocument)
@uindex.insert(uuid + document.version.to_raw_uuid, ptr + ts_ptr) unless options[:head]
rescue ArchiveVolume::VolumeCapacityExceeded
create_new_archive!
Please sign in to comment.
Something went wrong with that request. Please try again.