mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 00:09:04 +00:00
Add optional parent_seed to portable backup
This commit is contained in:
@@ -1154,6 +1154,7 @@ class PasswordManager:
|
||||
self.backup_manager,
|
||||
mode,
|
||||
dest,
|
||||
parent_seed=self.parent_seed,
|
||||
)
|
||||
print(colored(f"Database exported to '{path}'.", "green"))
|
||||
return path
|
||||
@@ -1165,7 +1166,12 @@ class PasswordManager:
|
||||
def handle_import_database(self, src: Path) -> None:
|
||||
"""Import a portable database file, replacing the current index."""
|
||||
try:
|
||||
import_backup(self.vault, self.backup_manager, src)
|
||||
import_backup(
|
||||
self.vault,
|
||||
self.backup_manager,
|
||||
src,
|
||||
parent_seed=self.parent_seed,
|
||||
)
|
||||
print(colored("Database imported successfully.", "green"))
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to import database: {e}", exc_info=True)
|
||||
|
@@ -55,6 +55,7 @@ def export_backup(
|
||||
dest_path: Path | None = None,
|
||||
*,
|
||||
publish: bool = False,
|
||||
parent_seed: str | None = None,
|
||||
) -> Path:
|
||||
"""Export the current vault state to a portable encrypted file."""
|
||||
|
||||
@@ -65,7 +66,11 @@ def export_backup(
|
||||
dest_path = dest_dir / EXPORT_NAME_TEMPLATE.format(ts=ts)
|
||||
|
||||
index_data = vault.load_index()
|
||||
seed = vault.encryption_manager.decrypt_parent_seed()
|
||||
seed = (
|
||||
parent_seed
|
||||
if parent_seed is not None
|
||||
else vault.encryption_manager.decrypt_parent_seed()
|
||||
)
|
||||
password = None
|
||||
if mode in (PortableMode.SEED_PLUS_PW, PortableMode.PW_ONLY):
|
||||
password = prompt_existing_password("Enter your master password: ")
|
||||
@@ -109,6 +114,7 @@ def import_backup(
|
||||
vault: Vault,
|
||||
backup_manager: BackupManager,
|
||||
path: Path,
|
||||
parent_seed: str | None = None,
|
||||
) -> None:
|
||||
"""Import a portable backup file and replace the current index."""
|
||||
|
||||
@@ -123,7 +129,11 @@ def import_backup(
|
||||
mode = PortableMode(wrapper.get("encryption_mode", PortableMode.SEED_ONLY.value))
|
||||
payload = base64.b64decode(wrapper["payload"])
|
||||
|
||||
seed = vault.encryption_manager.decrypt_parent_seed()
|
||||
seed = (
|
||||
parent_seed
|
||||
if parent_seed is not None
|
||||
else vault.encryption_manager.decrypt_parent_seed()
|
||||
)
|
||||
password = None
|
||||
if mode in (PortableMode.SEED_PLUS_PW, PortableMode.PW_ONLY):
|
||||
password = prompt_existing_password("Enter your master password: ")
|
||||
|
Reference in New Issue
Block a user