Skip to content

Commit c21d6b3

Browse files
committed
better none support
1 parent a2adc81 commit c21d6b3

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

nextdns_sync.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,25 @@ def sync_profiles(keys_to_sync: List[str], payload: Optional[Dict] = None) -> No
149149
payload = build_payload(data, keys_to_sync)
150150

151151
payload = alpha_sort_lists(payload)
152-
logger.info("[SYNC] Generated Payload: %s", json.dumps(payload, separators=(',', ':')))
152+
logger.debug("[SYNC] Generated Payload: %s", json.dumps(payload, separators=(',', ':')))
153153

154154
for profile_id in PROFILE_SYNC_LIST:
155-
for key in keys_to_sync:
156-
if key in payload:
157-
key_payload = payload[key]
158-
logger.info("[SYNC] Using Key [%s]", key)
159-
if "blocklists" in key_payload:
160-
logger.info("[SYNC] [blocklists] to be filtered")
161-
key_payload["blocklists"] = filter_blocklists(key_payload["blocklists"])
162-
try:
163-
if isinstance(key_payload, list):
164-
update_array_settings(profile_id, key, key_payload)
165-
else:
166-
update_profile_settings(profile_id, key_payload, key)
167-
logger.info("[SYNC] Successfully updated %s for profile %s.", key, profile_id)
168-
except Exception as e:
169-
logger.error("[SYNC] Failed to update %s for profile %s: %s", key, profile_id, e)
155+
if profile_id is not None:
156+
for key in keys_to_sync:
157+
if key in payload:
158+
key_payload = payload[key]
159+
logger.info("[SYNC] Using Key [%s]", key)
160+
if "blocklists" in key_payload:
161+
logger.debug("[SYNC] [blocklists] to be filtered")
162+
key_payload["blocklists"] = filter_blocklists(key_payload["blocklists"])
163+
try:
164+
if isinstance(key_payload, list):
165+
update_array_settings(profile_id, key, key_payload)
166+
else:
167+
update_profile_settings(profile_id, key_payload, key)
168+
logger.info("[SYNC] Successfully updated %s for profile %s.", key, profile_id)
169+
except Exception as e:
170+
logger.error("[SYNC] Failed to update %s for profile %s: %s", key, profile_id, e)
170171

171172
except Exception as e:
172173
logger.error("[SYNC] Failed to sync profiles: %s", e)

0 commit comments

Comments
 (0)