# Buggy code
def prepare(cls, params):
    """
    Used to validate existing repository when added.
    """

    # Build fake profile because we don't have it in the DB yet.
    profile = FakeProfile(
        FakeRepo(params["repo_url"], 999, params["extra_borg_arguments"]),
        "New Repo",
        params["ssh_key"],
    )

    ret = super().prepare(profile)
    if not ret["ok"]:
        return ret
    else:
        ret["ok"] = False  # Set back to false, so we can do our own checks here.

    cmd = ["borg", "info", "--info", "--json", "--log-json"]
    cmd.append(profile.repo.url)

    ret["additional_env"] = {
        "BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK": "yes",
        "BORG_RSH": "ssh -oStrictHostKeyChecking=no",
    }

    if params["password"] == "":
        ret["password"] = (
            "999999"  # Dummy password if the user didn't supply one. To avoid prompt.
        )
    else:
        ret["password"] = params["password"]
    ret["ok"] = True
    ret["cmd"] = cmd

    return ret


# Traceback (dbus.exceptions.DBusException)
2020-08-31 20:53:34,066 - vorta.borg.borg_thread - DEBUG - Using VortaSecretStorageKeyring keyring to store passwords.
2020-08-31 20:53:34,066 - asyncio - DEBUG - Using selector: EpollSelector
Traceback (most recent call last):
File "/home/user/.local/lib/python3.8/site-packages/vorta/views/repo_add_dialog.py", line 64, in run
params = BorgInitThread.prepare(self.values)
File "/home/user/.local/lib/python3.8/site-packages/vorta/borg/init.py", line 20, in prepare
ret = super().prepare(profile)
File "/home/user/.local/lib/python3.8/site-packages/vorta/borg/borg_thread.py", line 121, in prepare
ret['password'] = keyring.get_password('vorta-repo', profile.repo.url)
File "/home/user/.local/lib/python3.8/site-packages/vorta/keyring/secretstorage.py", line 30, in get_password
collection = secretstorage.get_default_collection(self.connection)
File "/usr/lib/python3/dist-packages/secretstorage/collection.py", line 155, in get_default_collection
return Collection(bus)
File "/usr/lib/python3/dist-packages/secretstorage/collection.py", line 42, in __init__
self.collection_props_iface.Get(COLLECTION_IFACE, 'Label',
File "/usr/lib/python3/dist-packages/secretstorage/util.py", line 31, in function_out
return function_in(*args, **kwargs)
File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 141, in __call__
return self._connection.call_blocking(self._named_service,
File "/usr/lib/python3/dist-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownObject: No such object path '/org/freedesktop/secrets/aliases/default'

# Fixed code
def prepare(cls, params):
    """
    Used to validate existing repository when added.
    """

    # Build fake profile because we don't have it in the DB yet. Assume unencrypted.
    profile = FakeProfile(
        FakeRepo(params["repo_url"], 999, params["extra_borg_arguments"], "none"),
        "New Repo",
        params["ssh_key"],
    )

    ret = super().prepare(profile)
    if not ret["ok"]:
        return ret
    else:
        ret["ok"] = False  # Set back to false, so we can do our own checks here.

    cmd = ["borg", "info", "--info", "--json", "--log-json"]
    cmd.append(profile.repo.url)

    ret["additional_env"] = {
        "BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK": "yes",
        "BORG_RSH": "ssh -oStrictHostKeyChecking=no",
    }

    if params["password"] == "":
        ret["password"] = (
            "999999"  # Dummy password if the user didn't supply one. To avoid prompt.
        )
    else:
        ret["password"] = params["password"]
        # Cannot tell if repo has encryption, assuming based off of password
        if not get_keyring().is_unlocked:
            ret["message"] = trans_late(
                "messages", "Please unlock your password manager."
            )
            return ret

    ret["ok"] = True
    ret["cmd"] = cmd

    return ret