class MyLocalPutio::DiskManager
Attributes
configuration[R]
logger[R]
Public Class Methods
new(configuration)
click to toggle source
# File lib/my-local-putio/disk_manager.rb, line 5 def initialize(configuration) @configuration = configuration @logger = configuration.logger end
Public Instance Methods
check_for_available_space_on_destinations!(needed_space)
click to toggle source
# File lib/my-local-putio/disk_manager.rb, line 10 def check_for_available_space_on_destinations!(needed_space) return unless configuration.disk_threshold [configuration.local_destination, configuration.temp_destination].each do |path| free_space = get_folder_free_space(path) next unless (free_space - configuration.disk_threshold) <= needed_space logger.log "Low disk threshold on path: #{path}! Stopping the script!" exit end end
get_folder_free_space(destination)
click to toggle source
# File lib/my-local-putio/disk_manager.rb, line 21 def get_folder_free_space(destination) space = `df -Pk #{destination}/ | awk 'NR==2 {print $4}'`.to_i (space/1024).to_i.round(2) end