mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-20 13:18:50 -04:00
Merge branch 'remove-invalid-accounts' into 'main'
remove things that fail to deserialize See merge request veilid/veilidchat!47
This commit is contained in:
commit
b835e10200
4 changed files with 36 additions and 9 deletions
|
@ -40,6 +40,13 @@ sealed class LocalAccount with _$LocalAccount {
|
||||||
required String name,
|
required String name,
|
||||||
}) = _LocalAccount;
|
}) = _LocalAccount;
|
||||||
|
|
||||||
factory LocalAccount.fromJson(dynamic json) =>
|
factory LocalAccount.fromJson(dynamic json) {
|
||||||
_$LocalAccountFromJson(json as Map<String, dynamic>);
|
try {
|
||||||
|
return _$LocalAccountFromJson(json as Map<String, dynamic>);
|
||||||
|
// Need to catch any errors here too
|
||||||
|
// ignore: avoid_catches_without_on_clauses
|
||||||
|
} catch (e, st) {
|
||||||
|
throw Exception('invalid local account: $e\n$st');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,13 @@ sealed class UserLogin with _$UserLogin {
|
||||||
required Timestamp lastActive,
|
required Timestamp lastActive,
|
||||||
}) = _UserLogin;
|
}) = _UserLogin;
|
||||||
|
|
||||||
factory UserLogin.fromJson(dynamic json) =>
|
factory UserLogin.fromJson(dynamic json) {
|
||||||
_$UserLoginFromJson(json as Map<String, dynamic>);
|
try {
|
||||||
|
return _$UserLoginFromJson(json as Map<String, dynamic>);
|
||||||
|
// Need to catch any errors here too
|
||||||
|
// ignore: avoid_catches_without_on_clauses
|
||||||
|
} catch (e, st) {
|
||||||
|
throw Exception('invalid user login: $e\n$st');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@ import 'package:async_tools/async_tools.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'package:veilid/veilid.dart';
|
import 'package:veilid/veilid.dart';
|
||||||
|
|
||||||
|
import '../veilid_support.dart';
|
||||||
|
import 'veilid_log.dart';
|
||||||
|
|
||||||
Future<T> tableScope<T>(
|
Future<T> tableScope<T>(
|
||||||
String name, Future<T> Function(VeilidTableDB tdb) callback,
|
String name, Future<T> Function(VeilidTableDB tdb) callback,
|
||||||
{int columnCount = 1}) async {
|
{int columnCount = 1}) async {
|
||||||
|
@ -48,11 +51,20 @@ abstract mixin class TableDBBackedJson<T> {
|
||||||
/// Load things from storage
|
/// Load things from storage
|
||||||
@protected
|
@protected
|
||||||
Future<T?> load() async {
|
Future<T?> load() async {
|
||||||
|
try {
|
||||||
final obj = await tableScope(tableName(), (tdb) async {
|
final obj = await tableScope(tableName(), (tdb) async {
|
||||||
final objJson = await tdb.loadStringJson(0, tableKeyName());
|
final objJson = await tdb.loadStringJson(0, tableKeyName());
|
||||||
return valueFromJson(objJson);
|
return valueFromJson(objJson);
|
||||||
});
|
});
|
||||||
return obj;
|
return obj;
|
||||||
|
} on Exception catch (e, st) {
|
||||||
|
veilidLoggy.debug(
|
||||||
|
'Unable to load data from table store: '
|
||||||
|
'${tableName()}:${tableKeyName()}',
|
||||||
|
e,
|
||||||
|
st);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Store things to storage
|
/// Store things to storage
|
||||||
|
|
|
@ -69,6 +69,7 @@ void processLog(VeilidLog log) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initVeilidLog(bool debugMode) {
|
void initVeilidLog(bool debugMode) {
|
||||||
|
// Always allow LOG_TRACE option
|
||||||
// ignore: do_not_use_environment
|
// ignore: do_not_use_environment
|
||||||
const isTrace = String.fromEnvironment('LOG_TRACE') != '';
|
const isTrace = String.fromEnvironment('LOG_TRACE') != '';
|
||||||
LogLevel logLevel;
|
LogLevel logLevel;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue