diff --git a/backend/handler/snapshots/write.py b/backend/handler/snapshots/write.py index 5f22ce2a1..26156d93b 100644 --- a/backend/handler/snapshots/write.py +++ b/backend/handler/snapshots/write.py @@ -493,6 +493,7 @@ async def _store_part( "user_id": plan.owner.id, "emulator": write.manifest.emulator, "emulator_version": write.manifest.emulator_version, + "origin_device_id": write.origin_device_id or write.device_id, } row: Save | State if is_save: @@ -507,7 +508,6 @@ async def _store_part( ), shape=entry.shape, format=entry.format, - origin_device_id=write.origin_device_id or write.device_id, core=write.manifest.core, core_version=write.manifest.core_version, ) diff --git a/backend/tests/handler/snapshots/test_write.py b/backend/tests/handler/snapshots/test_write.py index f987bf9a3..4c5d4f20b 100644 --- a/backend/tests/handler/snapshots/test_write.py +++ b/backend/tests/handler/snapshots/test_write.py @@ -82,6 +82,19 @@ async def test_the_first_push_creates_the_channel_and_points_it_at_the_snapshot( assert sync.base_snapshot_id == snapshot.id +async def test_the_pushed_save_and_states_carry_the_device_that_wrote_them( + admin_user: User, rom: Rom, hashed_file: RomFile, device: Device +): + result = await first_push(admin_user, rom, hashed_file, device_id=device.id) + + with sync_session() as session: + save = session.get_one(Save, result.snapshot.save_id) + state = session.get_one(State, result.snapshot.states[0].state_id) + assert result.snapshot.origin_device_id == device.id + assert save.origin_device_id == device.id + assert state.origin_device_id == device.id + + async def test_a_client_supplied_channel_id_creates_that_channel( admin_user: User, rom: Rom, hashed_file: RomFile ):