mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Don't allow load_status to return None
This commit is contained in:
parent
3611e7d62f
commit
c073d55b2f
3 changed files with 10 additions and 9 deletions
|
|
@ -57,7 +57,7 @@ async def collections_for_pair(
|
||||||
cache_key = _get_collections_cache_key(pair)
|
cache_key = _get_collections_cache_key(pair)
|
||||||
if from_cache:
|
if from_cache:
|
||||||
rv = load_status(status_path, pair.name, data_type="collections")
|
rv = load_status(status_path, pair.name, data_type="collections")
|
||||||
if rv and rv.get("cache_key", None) == cache_key:
|
if rv.get("cache_key", None) == cache_key:
|
||||||
return list(
|
return list(
|
||||||
_expand_collections_cache(
|
_expand_collections_cache(
|
||||||
rv["collections"], pair.config_a, pair.config_b
|
rv["collections"], pair.config_a, pair.config_b
|
||||||
|
|
|
||||||
|
|
@ -142,11 +142,11 @@ async def metasync_collection(collection, general, *, connector: aiohttp.TCPConn
|
||||||
try:
|
try:
|
||||||
cli_logger.info(f"Metasyncing {status_name}")
|
cli_logger.info(f"Metasyncing {status_name}")
|
||||||
|
|
||||||
status = (
|
status = load_status(
|
||||||
load_status(
|
general["status_path"],
|
||||||
general["status_path"], pair.name, collection.name, data_type="metadata"
|
pair.name,
|
||||||
)
|
collection.name,
|
||||||
or {}
|
data_type="metadata",
|
||||||
)
|
)
|
||||||
|
|
||||||
a = await storage_instance_from_config(collection.config_a, connector=connector)
|
a = await storage_instance_from_config(collection.config_a, connector=connector)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import importlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import click
|
import click
|
||||||
|
|
@ -186,11 +187,11 @@ def load_status(
|
||||||
base_path: str,
|
base_path: str,
|
||||||
pair: str,
|
pair: str,
|
||||||
collection: str | None = None,
|
collection: str | None = None,
|
||||||
data_type: str | None = None
|
data_type: str | None = None,
|
||||||
) -> dict | None:
|
) -> dict[str, Any]:
|
||||||
path = get_status_path(base_path, pair, collection, data_type)
|
path = get_status_path(base_path, pair, collection, data_type)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return None
|
return {}
|
||||||
assert_permissions(path, STATUS_PERMISSIONS)
|
assert_permissions(path, STATUS_PERMISSIONS)
|
||||||
|
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue