Class: SafeDb::Pull

Inherits:
Controller show all
Defined in:
lib/controller/db/pull.rb

Overview

If the removable drive path is configured and exists and contains the master index file, the pull use case backs up both file and master crypts (if necessary) and then refreshes them with the state that exists in the remote mirrored git directory and the indices on the removable drive path.

Instance Method Summary collapse

Methods inherited from Controller

#check_post_conditions, #check_pre_conditions, #flow, #initialize, #open_remote_backend_location, #post_validation, #pre_validation, #read_verse, #set_verse, #update_verse

Constructor Details

This class inherits a constructor from SafeDb::Controller

Instance Method Details

#executeObject

If the removable drive path is configured and exists and contains the master index file, the pull use case backs up both file and master crypts (if necessary) and then refreshes them with the state that exists in the remote mirrored git directory and the indices on the removable drive path.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/controller/db/pull.rb', line 15

def execute()

    puts ""

      removable_drive_path = xxx # ~~~~ read this from the --to variable
      removable_drive_file = File.join( removable_drive_path, Indices::MASTER_INDICES_FILE_NAME )
      removable_drive_file_exists = File.exist?( removable_drive_file ) && File.file?( removable_drive_file )

      puts "Removable Drive Location => #{removable_drive_path}"
      puts "Removable Drive Filepath => #{removable_drive_file}"

      if removable_drive_file_exists
drive_filename = TimeStamp.yyjjj_hhmm_sst() + "-" + Indices::MASTER_INDICES_FILE_NAME
drive_backup_filepath = File.join( removable_drive_path, drive_filename )
File.write( drive_backup_filepath, File.read( removable_drive_file ) )
puts "Backup of Clobbered File => #{drive_backup_filepath}"
      end

      clobbered_crypts_name = TimeStamp.yyjjj_hhmm_sst() + "-" + Indices::MASTER_CRYPTS_FOLDER_NAME
      clobbered_crypts_path = File.join( Indices::SAFE_DATABASE_FOLDER, clobbered_crypts_name )

      FileUtils.mkdir_p( clobbered_crypts_path )
      FileUtils.copy_entry( Indices::MASTER_CRYPTS_FOLDER_PATH, clobbered_crypts_path )


      puts "Backup of Clobbered Crypts => #{clobbered_crypts_path}"

      is_git = File.exist?( Indices::MASTER_CRYPTS_GIT_PATH ) && File.directory?( Indices::MASTER_CRYPTS_GIT_PATH )

    return


end