mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 07:18:47 +00:00
Merge pull request #506 from PR0M3TH3AN/codex/modify-passwordmanager-to-support-quick-unlock
Enable background sync when quick unlock
This commit is contained in:
@@ -530,6 +530,12 @@ class PasswordManager:
|
||||
# Initialize BIP85 and other managers
|
||||
self.initialize_bip85()
|
||||
self.initialize_managers()
|
||||
if (
|
||||
getattr(self, "config_manager", None)
|
||||
and self.config_manager.get_quick_unlock()
|
||||
):
|
||||
self.start_background_sync()
|
||||
else:
|
||||
self.sync_index_from_nostr()
|
||||
print(colored(f"Switched to seed profile {selected_fingerprint}.", "green"))
|
||||
|
||||
@@ -603,6 +609,12 @@ class PasswordManager:
|
||||
self.initialize_managers()
|
||||
self.locked = False
|
||||
self.update_activity()
|
||||
if (
|
||||
getattr(self, "config_manager", None)
|
||||
and self.config_manager.get_quick_unlock()
|
||||
):
|
||||
self.start_background_sync()
|
||||
else:
|
||||
self.sync_index_from_nostr()
|
||||
|
||||
def handle_existing_seed(self) -> None:
|
||||
@@ -775,6 +787,12 @@ class PasswordManager:
|
||||
|
||||
self.initialize_bip85()
|
||||
self.initialize_managers()
|
||||
if (
|
||||
getattr(self, "config_manager", None)
|
||||
and self.config_manager.get_quick_unlock()
|
||||
):
|
||||
self.start_background_sync()
|
||||
else:
|
||||
self.sync_index_from_nostr()
|
||||
return fingerprint # Return the generated or added fingerprint
|
||||
except BaseException:
|
||||
@@ -930,6 +948,12 @@ class PasswordManager:
|
||||
|
||||
self.initialize_bip85()
|
||||
self.initialize_managers()
|
||||
if (
|
||||
getattr(self, "config_manager", None)
|
||||
and self.config_manager.get_quick_unlock()
|
||||
):
|
||||
self.start_background_sync()
|
||||
else:
|
||||
self.sync_index_from_nostr()
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to encrypt and save parent seed: {e}", exc_info=True)
|
||||
|
@@ -6,6 +6,7 @@ import sys
|
||||
sys.path.append(str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
from password_manager.manager import PasswordManager
|
||||
from password_manager import manager as manager_module
|
||||
|
||||
|
||||
def test_unlock_triggers_sync(monkeypatch, tmp_path):
|
||||
@@ -26,3 +27,30 @@ def test_unlock_triggers_sync(monkeypatch, tmp_path):
|
||||
time.sleep(0.05)
|
||||
|
||||
assert called["sync"]
|
||||
|
||||
|
||||
def test_quick_unlock_background_sync(monkeypatch, tmp_path):
|
||||
pm = PasswordManager.__new__(PasswordManager)
|
||||
pm.profile_stack = [("rootfp", tmp_path, "seed")]
|
||||
pm.config_manager = SimpleNamespace(get_quick_unlock=lambda: True)
|
||||
|
||||
monkeypatch.setattr(manager_module, "derive_index_key", lambda s: b"k")
|
||||
monkeypatch.setattr(
|
||||
manager_module, "EncryptionManager", lambda *a, **k: SimpleNamespace()
|
||||
)
|
||||
monkeypatch.setattr(manager_module, "Vault", lambda *a, **k: SimpleNamespace())
|
||||
|
||||
pm.initialize_bip85 = lambda: None
|
||||
pm.initialize_managers = lambda: None
|
||||
pm.update_activity = lambda: None
|
||||
|
||||
called = {"bg": False}
|
||||
|
||||
def fake_bg():
|
||||
called["bg"] = True
|
||||
|
||||
pm.start_background_sync = fake_bg
|
||||
|
||||
pm.exit_managed_account()
|
||||
|
||||
assert called["bg"]
|
||||
|
Reference in New Issue
Block a user