minor clean up
This commit is contained in:
parent
d399d7caba
commit
54cdfa4685
2 changed files with 10 additions and 3 deletions
|
|
@ -342,6 +342,7 @@ def _add_parents(conn: Connection, *, location: str, hostname: str) -> "int | No
|
|||
d = _fake_entry(p, hostname=hostname, now=datetime.now(), parent_id=p_id)
|
||||
d = get_or_add(conn, d)
|
||||
if isinstance(d, dict):
|
||||
log.warning("Added forged parent: %a:%a", hostname, str(p))
|
||||
p_id = d["id"]
|
||||
else:
|
||||
p_id = d.id
|
||||
|
|
|
|||
|
|
@ -245,14 +245,15 @@ def _parse_pathspec(pathspec: str) -> "tuple[str | None, str]":
|
|||
|
||||
|
||||
def _clean_dirname(loc: str, *, force_absolute: bool = True) -> str:
|
||||
"""Ensure the given location ends with a single `/`.
|
||||
|
||||
If `force_absolute` is `True`, also ensure the location starts with `/`.
|
||||
"""
|
||||
if force_absolute and not loc.startswith("/"):
|
||||
loc = "/" + loc
|
||||
if not loc.endswith("/"):
|
||||
loc += "/"
|
||||
return loc
|
||||
# if loc != "/" and loc.endswith("/"):
|
||||
# return loc[:-1]
|
||||
# return loc
|
||||
|
||||
|
||||
_Hostname = str
|
||||
|
|
@ -456,6 +457,11 @@ def _ingest_ls_add_only(
|
|||
|
||||
|
||||
def _dict_from_lsfile(f: ls_parser.File) -> "dict[str, Any]":
|
||||
"""Create a dict compatible with `models.File`.
|
||||
|
||||
This avoids creating a dataclass instance and calling `asdict` on it, which
|
||||
is a relatively expensive operation.
|
||||
"""
|
||||
mode = f.mode[0]
|
||||
if mode == "-":
|
||||
mode = "f"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue