Changeset View
Changeset View
Standalone View
Standalone View
swh/journal/replay.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import logging | import logging | ||||
from swh.storage import HashCollision | from swh.storage import HashCollision | ||||
from swh.objstorage.objstorage import ID_HASH_ALGO | |||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
def process_replay_objects(all_objects, *, storage): | def process_replay_objects(all_objects, *, storage): | ||||
for (object_type, objects) in all_objects.items(): | for (object_type, objects) in all_objects.items(): | ||||
_insert_objects(object_type, objects, storage) | _insert_objects(object_type, objects, storage) | ||||
Show All 17 Lines | elif object_type == 'origin_visit': | ||||
storage.origin_visit_upsert([ | storage.origin_visit_upsert([ | ||||
{ | { | ||||
**obj, | **obj, | ||||
'origin': storage.origin_add_one(obj['origin']) | 'origin': storage.origin_add_one(obj['origin']) | ||||
} | } | ||||
for obj in objects]) | for obj in objects]) | ||||
else: | else: | ||||
assert False | assert False | ||||
def process_replay_objects_content(all_objects, *, src, dst): | |||||
for (object_type, objects) in all_objects.items(): | |||||
if object_type != 'content': | |||||
logger.warning('Received a series of %s, this should not happen', | |||||
object_type) | |||||
vlorentz: inconsistent with the behavior of `_insert_objects` (which asserts False).
I have a preference… | |||||
Not Done Inline ActionsThinking about it, it's probably better to log. Could you raise the log level to warning (so it doesn't go unnoticed), and make _insert_objects do that too? vlorentz: Thinking about it, it's probably better to log.
Could you raise the log level to warning (so… | |||||
Done Inline ActionsI think I also prefer this second solution, i will douardda: I think I also prefer this second solution, i will | |||||
continue | |||||
for obj in objects: | |||||
if obj['status'] == 'visible': | |||||
obj_id = obj[ID_HASH_ALGO] | |||||
obj = src.get(obj_id) | |||||
dst.add(obj, obj_id=obj_id) |
inconsistent with the behavior of _insert_objects (which asserts False).
I have a preference to using the existing behavior (crashing) for both instead of just logging, but that's up to you