Method: Reedb::Vault.create_vault
- Defined in:
- lib/reedb.rb
.create_vault(name, path, passphrase, encryption = :auto) ⇒ Object
Creates a new vault on the current system. Returns nil if vault already existed at location. Returns a token if the creation and authentication was successful on the user side.
Also adds that token to the @@tokens list.
! THROWS A LOT OF EXCEPTIONS !
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
# File 'lib/reedb.rb', line 570 def create_vault(name, path, passphrase, encryption = :auto) # Creates new UUIDs until one is found that doesn't already exist in the scope uuid = UUID.new loop do uuid = uuid.generate (break) unless @@config[:vaults].include?(uuid) end # Create actual Vault object # This throws errors! tmp_vault = ReeVault.new("#{name}", "#{path}", encryption).create("#{passphrase}") # Creates a metavault with name, path, size and uuid to be tracked on the system # metavault = MetaVault.new("#{name}", "#{path}", 0, uuid) # Adds vault to the active set of vaults @@active_vaults[uuid] = tmp_vault # Track the vault in the config track_vault(name, path, 0, uuid) # Generate a token token = generate_token(uuid, path) # Generate a token for the debouncer and remove it if the vault was already accessable debouncer_token = generate_token(uuid, path) check = mirror_debounce(uuid, debouncer_token, Reedb::DEB_ADD) Reedb::remove_token(uuid, debouncer_token) unless check # Then return the token for the user token.delete!("\n") return token end |