Module: Flydata::InitialSyncChecks

Included in:
SourceMysql::MysqlCompatibilityCheck
Defined in:
lib/flydata/compatibility_check.rb

Overview

Collection of checks for initial sync

Instance Method Summary collapse

Instance Method Details

#check_writing_permissionsObject

Checks permission of @dump_dir and @backup_dir

Requires

@dump_dir
@backup_dir

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/flydata/compatibility_check.rb', line 45

def check_writing_permissions
  write_errors = []
  paths_to_check = [FLYDATA_HOME]
  paths_to_check << @dump_dir unless @dump_dir.to_s.empty?
  paths_to_check << @backup_dir unless @backup_dir.to_s.empty?
  paths_to_check.each do |path|
    full_path = File.expand_path(path)
    full_path = File.dirname(full_path) unless File.directory?(full_path)
    write_errors << full_path unless File.writable?(full_path) and File.executable?(full_path)
  end
  unless write_errors.empty?
    error_dir = write_errors.join(", ")
    raise FlydataCore::CompatibilityError, "We cannot access the directories: #{error_dir}"
  end
end