Class: YOLOBackup::StoragePool::File
- Inherits:
-
YOLOBackup::StoragePool
- Object
- YOLOBackup::StoragePool
- YOLOBackup::StoragePool::File
- Defined in:
- lib/yolo_backup/storage_pool/file.rb
Defined Under Namespace
Classes: Cleaner
Constant Summary collapse
- OPTIONS =
%w{ path }
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Attributes inherited from YOLOBackup::StoragePool
Instance Method Summary collapse
- #cleanup(server) ⇒ Object
-
#initialize(name, options = nil) ⇒ File
constructor
A new instance of File.
- #initiate_backup(server) {|path| ... } ⇒ Object
- #latest_backup(server) ⇒ Object
- #ready? ⇒ Boolean
- #statistics ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/yolo_backup/storage_pool/file.rb', line 12 def path @path end |
Instance Method Details
#cleanup(server) ⇒ Object
53 54 55 56 |
# File 'lib/yolo_backup/storage_pool/file.rb', line 53 def cleanup(server) cleaner = Cleaner.new(self, server) cleaner.cleanup end |
#initiate_backup(server) {|path| ... } ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/yolo_backup/storage_pool/file.rb', line 44 def initiate_backup(server, &block) server_path = server_path(server) path = "#{server_path}/#{Time.now.iso8601}/" yield(path) latest_path = "#{server_path}/latest" ::File.unlink(latest_path) if ::File.symlink?(latest_path) ::File.symlink(path, latest_path) end |
#latest_backup(server) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/yolo_backup/storage_pool/file.rb', line 37 def latest_backup(server) server_path = server_path(server) return nil unless ::File.directory?(server_path) && ::File.symlink?("#{server_path}/latest") && ::File.directory?("#{server_path}/latest") target = ::File.basename(::File.readlink("#{server_path}/latest")) Time.parse(target) end |
#ready? ⇒ Boolean
33 34 35 |
# File 'lib/yolo_backup/storage_pool/file.rb', line 33 def ready? ::File.directory?(base_path) && ::File.readable?(base_path) end |
#statistics ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/yolo_backup/storage_pool/file.rb', line 25 def statistics stats = Sys::Filesystem.stat(base_path) { capacity: stats.blocks * stats.block_size, available: stats.blocks_available * stats.block_size } end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/yolo_backup/storage_pool/file.rb', line 21 def to_s "#{name} (#{wildcard_path})" end |