fix(#1122): log the slot lookup's own source, survive a version read

Review findings on the logging commit:

- The notify decision line said "live list" or "cached list" by
  repeating the lookup. The lookup now reports which list answered,
  so the line cannot drift from it.
- Reading the app version at startup can throw. It now logs the error
  and keeps "unknown" instead of failing startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix/1118-factory-reset-delete-on-send
diffwireauto 3 weeks ago committed by Strycher
parent 43ec4d2fa3
commit 8709351d57

@ -10553,7 +10553,8 @@ class MeshCoreConnector extends ChangeNotifier {
// Evaluated against resolvedText so a translated mention still matches.
// #1062: an unknown slot means an unknown PSK means an unknowable mode;
// fail closed (no notification) rather than defaulting to noisy.
final slotChannel = _findChannelByIndex(channelIndex);
final slotLookup = _findChannelByIndexWithSource(channelIndex);
final slotChannel = slotLookup.channel;
if (slotChannel == null &&
_unconfirmedChannelSlots.contains(channelIndex)) {
_appDebugLogService?.warn(
@ -10581,17 +10582,12 @@ class MeshCoreConnector extends ChangeNotifier {
'mentions only, no mention',
_ => null,
};
final slotSource = slotChannel == null
? 'no channel in slot'
: _channels.any((c) => c.index == channelIndex)
? 'live list'
: 'cached list';
_appDebugLogService?.info(
'CHAN NOTIFY slot $channelIndex "$label": radio '
'${AppSettingsService.radioScopePrefix(selfPublicKeyHex)}, slot holds '
'"${slotChannel?.name ?? ''}" psk '
'${AppSettingsService.pskFingerprint(slotChannel?.pskHex)} '
'($slotSource), mode ${mode.name} (${resolved.source}) -> '
'(${slotLookup.source}), mode ${mode.name} (${resolved.source}) -> '
'${suppressed == null ? 'posting' : 'suppressed, $suppressed'}',
tag: 'Notification',
);
@ -11154,19 +11150,28 @@ class MeshCoreConnector extends ChangeNotifier {
return contact.type != advTypeRepeater;
}
Channel? _findChannelByIndex(int index) {
Channel? _findChannelByIndex(int index) =>
_findChannelByIndexWithSource(index).channel;
/// [_findChannelByIndex] plus which list answered, for the log.
({Channel? channel, String source}) _findChannelByIndexWithSource(int index) {
// #1062: an unconfirmed slot's contents are unknown. Returning the cached
// occupant here is how a stale identity (wrong PSK, wrong name) attached
// itself to live traffic; fail closed instead.
if (_unconfirmedChannelSlots.contains(index)) return null;
return _channels.cast<Channel?>().firstWhere(
(c) => c?.index == index,
orElse: () => null,
) ??
_cachedChannels.cast<Channel?>().firstWhere(
(c) => c?.index == index,
orElse: () => null,
);
if (_unconfirmedChannelSlots.contains(index)) {
return (channel: null, source: 'slot unconfirmed');
}
final live = _channels.cast<Channel?>().firstWhere(
(c) => c?.index == index,
orElse: () => null,
);
if (live != null) return (channel: live, source: 'live list');
final cached = _cachedChannels.cast<Channel?>().firstWhere(
(c) => c?.index == index,
orElse: () => null,
);
if (cached != null) return (channel: cached, source: 'cached list');
return (channel: null, source: 'no channel in slot');
}
void _maybeIncrementChannelUnread(

@ -116,8 +116,12 @@ void main() async {
appDebugLogService,
enabled: appSettingsService.settings.appDebugLogEnabled,
);
final packageInfo = await PackageInfo.fromPlatform();
appLogger.appVersion = '${packageInfo.version}+${packageInfo.buildNumber}';
try {
final packageInfo = await PackageInfo.fromPlatform();
appLogger.appVersion = '${packageInfo.version}+${packageInfo.buildNumber}';
} catch (e) {
appLogger.error('Could not read the app version: $e', tag: 'App');
}
appLogger.info('App ${appLogger.appVersion} started', tag: 'App');
appSettingsService.logLoadReport();

Loading…
Cancel
Save

Powered by TurnKey Linux.