Improved doc.
This commit is contained in:
parent
eb03d82fdf
commit
97961e7020
2 changed files with 48 additions and 7 deletions
|
@ -5,7 +5,14 @@ class Store
|
||||||
include ApplicationLib
|
include ApplicationLib
|
||||||
after_destroy :destroy_provider
|
after_destroy :destroy_provider
|
||||||
|
|
||||||
# add new file
|
=beging
|
||||||
|
|
||||||
|
add new file to store
|
||||||
|
|
||||||
|
store_file_id = Store::File.add(binary_data)
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
def self.add(data)
|
def self.add(data)
|
||||||
sha = Digest::SHA256.hexdigest( data )
|
sha = Digest::SHA256.hexdigest( data )
|
||||||
|
|
||||||
|
@ -27,7 +34,16 @@ class Store
|
||||||
file
|
file
|
||||||
end
|
end
|
||||||
|
|
||||||
# read content
|
=begin
|
||||||
|
|
||||||
|
read content of a file
|
||||||
|
|
||||||
|
store = Store::File.find(123)
|
||||||
|
|
||||||
|
store.content # returns binary
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
def content
|
def content
|
||||||
adapter = self.class.load_adapter("Store::Provider::#{provider}")
|
adapter = self.class.load_adapter("Store::Provider::#{provider}")
|
||||||
if sha
|
if sha
|
||||||
|
@ -39,7 +55,21 @@ class Store
|
||||||
c
|
c
|
||||||
end
|
end
|
||||||
|
|
||||||
# check data and sha, in case fix it
|
=begin
|
||||||
|
|
||||||
|
file system check of store, check data and sha (in case fix it)
|
||||||
|
|
||||||
|
Store::File.verify
|
||||||
|
|
||||||
|
read each file which should be in backend and verify agsinst sha hash
|
||||||
|
|
||||||
|
in case of fixing sha hash use:
|
||||||
|
|
||||||
|
|
||||||
|
Store::File.verify(true)
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
def self.verify(fix_it = nil)
|
def self.verify(fix_it = nil)
|
||||||
success = true
|
success = true
|
||||||
Store::File.all.each {|item|
|
Store::File.all.each {|item|
|
||||||
|
@ -58,9 +88,20 @@ class Store
|
||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
# move file from one to other provider
|
=begin
|
||||||
# e. g. Store::File.move('File', 'DB')
|
|
||||||
# e. g. Store::File.move('DB', 'File')
|
move file from one to other provider
|
||||||
|
|
||||||
|
move files from file backend to db
|
||||||
|
|
||||||
|
Store::File.move('File', 'DB')
|
||||||
|
|
||||||
|
move files from db backend to fs
|
||||||
|
|
||||||
|
Store::File.move('DB', 'File')
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
def self.move(source, target)
|
def self.move(source, target)
|
||||||
adapter_source = load_adapter("Store::Provider::#{source}")
|
adapter_source = load_adapter("Store::Provider::#{source}")
|
||||||
adapter_target = load_adapter("Store::Provider::#{target}")
|
adapter_target = load_adapter("Store::Provider::#{target}")
|
||||||
|
|
|
@ -273,7 +273,7 @@ class AssetsTest < ActiveSupport::TestCase
|
||||||
o2['updated_at'] = o2['updated_at'].to_s
|
o2['updated_at'] = o2['updated_at'].to_s
|
||||||
end
|
end
|
||||||
return true if (o1.to_a - o2.to_a).empty?
|
return true if (o1.to_a - o2.to_a).empty?
|
||||||
puts "ERROR: difference \n1: #{o1.inspect}\n2: #{o2.inspect}\ndiff: #{(o1.to_a - o2.to_a).inspect}"
|
#puts "ERROR: difference \n1: #{o1.inspect}\n2: #{o2.inspect}\ndiff: #{(o1.to_a - o2.to_a).inspect}"
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue