Class: Backup::Storage::Yandex::Disk
- Inherits:
-
Base
- Object
- Base
- Backup::Storage::Yandex::Disk
- Includes:
- Storage::Cycler
- Defined in:
- lib/yandex/disk/backup/storage.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(model, storage_id = nil, &block) ⇒ Disk
constructor
A new instance of Disk.
- #remove!(package) ⇒ Object
- #storage_name ⇒ Object
- #transfer! ⇒ Object
Constructor Details
#initialize(model, storage_id = nil, &block) ⇒ Disk
Returns a new instance of Disk.
12 13 14 15 16 |
# File 'lib/yandex/disk/backup/storage.rb', line 12 def initialize(model, storage_id = nil, &block) super instance_eval(&block) if block_given? @path ||= '/backups' end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
10 11 12 |
# File 'lib/yandex/disk/backup/storage.rb', line 10 def access_token @access_token end |
Instance Method Details
#connection ⇒ Object
18 19 20 |
# File 'lib/yandex/disk/backup/storage.rb', line 18 def connection ::Yandex::Disk::Client.new(:access_token => access_token, :timeout => 500) end |
#remove!(package) ⇒ Object
33 34 35 36 37 |
# File 'lib/yandex/disk/backup/storage.rb', line 33 def remove!(package) Logger.info "Removing backup package dated #{ package.time }..." remote_path = remote_path_for(package) connection.delete(remote_path) end |
#storage_name ⇒ Object
39 40 41 |
# File 'lib/yandex/disk/backup/storage.rb', line 39 def storage_name 'Yandex::Disk' end |
#transfer! ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/yandex/disk/backup/storage.rb', line 22 def transfer! disk = connection disk.mkdir_p(remote_path) package.filenames.each do |filename| src = File.join(Config.tmp_path, filename) dest = File.join(remote_path, filename) Logger.info "Storing '#{ dest }'..." disk.put!(src, dest) end end |