Commit c82dbc6b authored by nimrod's avatar nimrod
Browse files

download-password-db: Close open passhole databases.

parent 961b25e0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -18,6 +18,18 @@ DEST = os.path.expanduser(f"~/{ os.path.dirname(DB_PATH) }")
SOURCE = f"nextcloud:{DB_PATH}"


def close_passhole():
    """Try to close passhole. Ignore all failures including no open database
    and failed import (to avoid dependency on passhole)."""
    try:
        # pylint: disable=import-outside-toplevel
        from pykeepass_cache.pykeepass_cache import close

        close()
    except (ImportError, OSError):
        pass


if __name__ == "__main__":
    username = input(f"Enter username (defaults to {getpass.getuser()}): ")
    if not username:
@@ -31,6 +43,7 @@ if __name__ == "__main__":
        check=True,
        text=True,
    ).stdout.strip()
    close_passhole()
    os.execvp(  # nosec
        "rclone",
        [