diff --git a/lib/services/link/sync/link_sync_protocol.dart b/lib/services/link/sync/link_sync_protocol.dart index b1df397da..9378bb54c 100644 --- a/lib/services/link/sync/link_sync_protocol.dart +++ b/lib/services/link/sync/link_sync_protocol.dart @@ -1,3 +1,5 @@ +import 'package:mornye/services/cover_store.dart'; + /// Mornye Link collections and history sync (unit L4). Both directions use /// the same JSON, so the desktop (server) and the phone (client) share one /// store implementation per database. @@ -224,13 +226,14 @@ class LinkHistoryEvent { } } -/// Artwork another device can load: http and https URLs only. +/// Artwork another device can load: http and https URLs only, without the +/// loopback URLs older builds recorded, which named the author's own proxy. String? linkSyncRemoteArtwork(Object? value) { final artwork = _string(value); if (artwork == null) return null; final lower = artwork.toLowerCase(); return lower.startsWith('https://') || lower.startsWith('http://') - ? artwork + ? durableCoverReference(artwork) : null; } diff --git a/test/link_history_sync_test.dart b/test/link_history_sync_test.dart index fb7f498dd..c5d25db2f 100644 --- a/test/link_history_sync_test.dart +++ b/test/link_history_sync_test.dart @@ -186,4 +186,33 @@ void main() { isNull, ); }); + + test('loopback artwork an older build recorded is never synced', () async { + final directory = await linkSyncTempDirectory(); + final db = await openLinkListeningDatabase(directory, 'phone'); + final store = LinkHistorySyncStore(() async => db); + const loopback = 'http://127.0.0.1:41234/7f3a'; + await db.insert('listening', { + 'day': '2026-10-20', + 'track_key': '/a.flac', + 'title': 'Song', + 'artist': 'Artist', + 'album': 'Album', + 'artwork': loopback, + 'milliseconds': 1000, + 'plays': 0, + }); + final page = await store.eventsSince(0); + expect(page.items.single.trackKey, '/a.flac'); + expect(page.items.single.artwork, isNull); + final event = LinkHistoryEvent.fromJson({ + 'origin': 'peer', + 'day': '2026-10-20', + 'trackKey': '/b.flac', + 'artwork': loopback, + 'ms': 1000, + 'plays': 0, + }); + expect(event!.artwork, isNull); + }); }