Class: Slot
- Inherits:
-
Bit
- Object
- ActiveRecord::Base
- Bit
- Slot
show all
- Defined in:
- lib/sinatra-s3/models/slot.rb
Instance Method Summary
collapse
Methods inherited from Bit
#access_readable, #acl_label, #acl_list, acl_text, #acp_readable_by?, #acp_writable_by?, #check_access, diff, #diff, #each_piece, #get_acls_for_bin, #git_object, #git_repository, #git_repository_path, #git_update, #grant, #objectish, #owned_by?, #readable_by?, #versioning_enabled?, #writable_by?
Instance Method Details
#etag ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'lib/sinatra-s3/models/slot.rb', line 8
def etag
if self.obj.respond_to? :etag
self.obj.etag
elsif self.obj.respond_to? :md5
self.obj.md5
else
%{"#{MD5.md5(self.obj)}"}
end
end
|
#fullpath ⇒ Object
6
|
# File 'lib/sinatra-s3/models/slot.rb', line 6
def fullpath; File.join(S3::STORAGE_PATH, obj.path) end
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/sinatra-s3/models/slot.rb', line 22
def metainfo
mii = RubyTorrent::MetaInfoInfo.new
mii.name = self.name
mii.length = self.obj.size
mii.md5sum = self.obj.md5
mii.piece_length = 512.kilobytes
mii.pieces = ""
i = 0
each_piece([self.fullpath], mii.piece_length) do |piece|
mii.pieces += Digest::SHA1.digest(piece)
i += 1
end
mi = RubyTorrent::MetaInfo.new
mi.info = mii
mi
end
|
#remove_from_filesystem ⇒ Object
18
19
20
|
# File 'lib/sinatra-s3/models/slot.rb', line 18
def remove_from_filesystem
FileUtils.rm_f fullpath
end
|