Class: SelfSDK::StorageMigrator

Inherits:
Object
  • Object
show all
Defined in:
lib/storage.rb

Instance Method Summary collapse

Constructor Details

#initialize(db, storage_folder, app_id) ⇒ StorageMigrator

Returns a new instance of StorageMigrator.



151
152
153
154
155
156
157
# File 'lib/storage.rb', line 151

def initialize(db, storage_folder, app_id)
  @db = db
  # Old versions of the sdk using that same storage folder shouldn't be affected in any way

  @base_path = "#{storage_folder}/#{app_id.split(':').first}"
  @app_id = app_id
end

Instance Method Details

#migrateObject



159
160
161
162
163
164
165
166
167
168
169
# File 'lib/storage.rb', line 159

def migrate
  return unless File.exist?(@base_path)

  # Parse the account information.
  accounts = parse_accounts

  persist_accounts(accounts)

  # Depreciate the base path.
  File.rename("#{@base_path}", "#{@base_path}-depreciated")
end