Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
774829ece5 | ||
|
|
33949b92c0 |
@@ -19,6 +19,8 @@ class SyncLogEntry {
|
|||||||
required this.id,
|
required this.id,
|
||||||
required this.result,
|
required this.result,
|
||||||
this.errorMessage,
|
this.errorMessage,
|
||||||
|
this.stackTrace,
|
||||||
|
this.isPermanent = false,
|
||||||
required this.protocol,
|
required this.protocol,
|
||||||
required this.emailsFetched,
|
required this.emailsFetched,
|
||||||
required this.emailsSkipped,
|
required this.emailsSkipped,
|
||||||
@@ -34,6 +36,8 @@ class SyncLogEntry {
|
|||||||
final int id;
|
final int id;
|
||||||
final String result; // 'ok' or 'error'
|
final String result; // 'ok' or 'error'
|
||||||
final String? errorMessage;
|
final String? errorMessage;
|
||||||
|
final String? stackTrace;
|
||||||
|
final bool isPermanent;
|
||||||
final String protocol; // 'imap' or 'jmap'
|
final String protocol; // 'imap' or 'jmap'
|
||||||
final int emailsFetched;
|
final int emailsFetched;
|
||||||
final int emailsSkipped;
|
final int emailsSkipped;
|
||||||
@@ -54,6 +58,8 @@ abstract class SyncLogRepository {
|
|||||||
required String accountId,
|
required String accountId,
|
||||||
required bool success,
|
required bool success,
|
||||||
String? errorMessage,
|
String? errorMessage,
|
||||||
|
String? stackTrace,
|
||||||
|
bool isPermanent = false,
|
||||||
required String protocol,
|
required String protocol,
|
||||||
required int emailsFetched,
|
required int emailsFetched,
|
||||||
required int emailsSkipped,
|
required int emailsSkipped,
|
||||||
@@ -81,6 +87,8 @@ class NoOpSyncLogRepository implements SyncLogRepository {
|
|||||||
required String accountId,
|
required String accountId,
|
||||||
required bool success,
|
required bool success,
|
||||||
String? errorMessage,
|
String? errorMessage,
|
||||||
|
String? stackTrace,
|
||||||
|
bool isPermanent = false,
|
||||||
required String protocol,
|
required String protocol,
|
||||||
required int emailsFetched,
|
required int emailsFetched,
|
||||||
required int emailsSkipped,
|
required int emailsSkipped,
|
||||||
|
|||||||
@@ -260,6 +260,8 @@ class _AccountSync implements _SyncLoop {
|
|||||||
accountId: account.id,
|
accountId: account.id,
|
||||||
success: false,
|
success: false,
|
||||||
errorMessage: e.toString(),
|
errorMessage: e.toString(),
|
||||||
|
stackTrace: st.toString(),
|
||||||
|
isPermanent: isPermanent,
|
||||||
protocol: 'imap',
|
protocol: 'imap',
|
||||||
emailsFetched: 0,
|
emailsFetched: 0,
|
||||||
emailsSkipped: 0,
|
emailsSkipped: 0,
|
||||||
@@ -513,6 +515,8 @@ class _JmapAccountSync implements _SyncLoop {
|
|||||||
accountId: account.id,
|
accountId: account.id,
|
||||||
success: false,
|
success: false,
|
||||||
errorMessage: e.toString(),
|
errorMessage: e.toString(),
|
||||||
|
stackTrace: st.toString(),
|
||||||
|
isPermanent: isPermanent,
|
||||||
protocol: 'jmap',
|
protocol: 'jmap',
|
||||||
emailsFetched: 0,
|
emailsFetched: 0,
|
||||||
emailsSkipped: 0,
|
emailsSkipped: 0,
|
||||||
|
|||||||
@@ -192,6 +192,9 @@ class SyncLogs extends Table {
|
|||||||
DateTimeColumn get finishedAt => dateTime()();
|
DateTimeColumn get finishedAt => dateTime()();
|
||||||
// Added in schema v13: raw protocol log when account.verbose == true.
|
// Added in schema v13: raw protocol log when account.verbose == true.
|
||||||
TextColumn get protocolLog => text().nullable()();
|
TextColumn get protocolLog => text().nullable()();
|
||||||
|
// Added in schema v33: stack trace and permanent flag for error entries.
|
||||||
|
TextColumn get errorStackTrace => text().nullable()();
|
||||||
|
BoolColumn get isPermanent => boolean().withDefault(const Constant(false))();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Per-mailbox breakdown for a single sync cycle.
|
/// Per-mailbox breakdown for a single sync cycle.
|
||||||
@@ -329,7 +332,7 @@ class AppDatabase extends _$AppDatabase {
|
|||||||
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get schemaVersion => 32;
|
int get schemaVersion => 33;
|
||||||
|
|
||||||
Future<void> _createEmailFts() async {
|
Future<void> _createEmailFts() async {
|
||||||
await customStatement('''
|
await customStatement('''
|
||||||
@@ -570,6 +573,10 @@ class AppDatabase extends _$AppDatabase {
|
|||||||
if (from < 32) {
|
if (from < 32) {
|
||||||
await m.createTable(localSieveApplied);
|
await m.createTable(localSieveApplied);
|
||||||
}
|
}
|
||||||
|
if (from >= 7 && from < 33) {
|
||||||
|
await m.addColumn(syncLogs, syncLogs.errorStackTrace);
|
||||||
|
await m.addColumn(syncLogs, syncLogs.isPermanent);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ class SyncLogRepositoryImpl implements SyncLogRepository {
|
|||||||
required String accountId,
|
required String accountId,
|
||||||
required bool success,
|
required bool success,
|
||||||
String? errorMessage,
|
String? errorMessage,
|
||||||
|
String? stackTrace,
|
||||||
|
bool isPermanent = false,
|
||||||
required String protocol,
|
required String protocol,
|
||||||
required int emailsFetched,
|
required int emailsFetched,
|
||||||
required int emailsSkipped,
|
required int emailsSkipped,
|
||||||
@@ -30,6 +32,8 @@ class SyncLogRepositoryImpl implements SyncLogRepository {
|
|||||||
accountId: accountId,
|
accountId: accountId,
|
||||||
result: success ? 'ok' : 'error',
|
result: success ? 'ok' : 'error',
|
||||||
errorMessage: Value(errorMessage),
|
errorMessage: Value(errorMessage),
|
||||||
|
errorStackTrace: Value(stackTrace),
|
||||||
|
isPermanent: Value(isPermanent),
|
||||||
protocol: Value(protocol),
|
protocol: Value(protocol),
|
||||||
itemsSynced: Value(emailsFetched),
|
itemsSynced: Value(emailsFetched),
|
||||||
emailsSkipped: Value(emailsSkipped),
|
emailsSkipped: Value(emailsSkipped),
|
||||||
@@ -75,6 +79,8 @@ class SyncLogRepositoryImpl implements SyncLogRepository {
|
|||||||
id: r.id,
|
id: r.id,
|
||||||
result: r.result,
|
result: r.result,
|
||||||
errorMessage: r.errorMessage,
|
errorMessage: r.errorMessage,
|
||||||
|
stackTrace: r.errorStackTrace,
|
||||||
|
isPermanent: r.isPermanent,
|
||||||
protocol: r.protocol,
|
protocol: r.protocol,
|
||||||
emailsFetched: r.itemsSynced,
|
emailsFetched: r.itemsSynced,
|
||||||
emailsSkipped: r.emailsSkipped,
|
emailsSkipped: r.emailsSkipped,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
|
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
|
||||||
@@ -8,6 +8,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:sharedinbox/core/models/account.dart';
|
import 'package:sharedinbox/core/models/account.dart';
|
||||||
import 'package:sharedinbox/di.dart';
|
import 'package:sharedinbox/di.dart';
|
||||||
|
import 'package:sharedinbox/ui/utils/about_markdown.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class AboutScreen extends ConsumerStatefulWidget {
|
class AboutScreen extends ConsumerStatefulWidget {
|
||||||
@@ -19,57 +20,15 @@ class AboutScreen extends ConsumerStatefulWidget {
|
|||||||
|
|
||||||
class _AboutScreenState extends ConsumerState<AboutScreen> {
|
class _AboutScreenState extends ConsumerState<AboutScreen> {
|
||||||
final Future<PackageInfo> _packageInfoFuture = PackageInfo.fromPlatform();
|
final Future<PackageInfo> _packageInfoFuture = PackageInfo.fromPlatform();
|
||||||
|
final Future<AndroidDeviceInfo?> _androidInfoFuture = getAndroidDeviceInfo();
|
||||||
late final Stream<List<Account>> _accountsStream;
|
late final Stream<List<Account>> _accountsStream;
|
||||||
|
|
||||||
static const _gitHash = String.fromEnvironment('GIT_HASH');
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_accountsStream = ref.read(accountRepositoryProvider).observeAccounts();
|
_accountsStream = ref.read(accountRepositoryProvider).observeAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
String _buildMarkdown(
|
|
||||||
BuildContext context,
|
|
||||||
PackageInfo? pkg,
|
|
||||||
int imapCount,
|
|
||||||
int jmapCount,
|
|
||||||
) {
|
|
||||||
final size = MediaQuery.of(context).size;
|
|
||||||
final pixelRatio = MediaQuery.of(context).devicePixelRatio;
|
|
||||||
final physW = (size.width * pixelRatio).toInt();
|
|
||||||
final physH = (size.height * pixelRatio).toInt();
|
|
||||||
final version =
|
|
||||||
pkg != null ? '${pkg.version}+${pkg.buildNumber}' : 'unknown';
|
|
||||||
final versionDisplay = _gitHash.isNotEmpty
|
|
||||||
? '[$version](https://codeberg.org/guettli/sharedinbox/commit/$_gitHash)'
|
|
||||||
: version;
|
|
||||||
final osName = _capitalize(Platform.operatingSystem);
|
|
||||||
final isDark = MediaQuery.of(context).platformBrightness == Brightness.dark;
|
|
||||||
|
|
||||||
final gitCommitLine = _gitHash.isNotEmpty
|
|
||||||
? '| Git Commit | [$_gitHash](https://codeberg.org/guettli/sharedinbox/commit/$_gitHash) |\n'
|
|
||||||
: '';
|
|
||||||
return '## [sharedinbox.de](https://sharedinbox.de)\n\n'
|
|
||||||
'| Property | Value |\n'
|
|
||||||
'|----------|-------|\n'
|
|
||||||
'| App Version | $versionDisplay |\n'
|
|
||||||
'$gitCommitLine'
|
|
||||||
'| Platform | ${Platform.operatingSystem} |\n'
|
|
||||||
'| $osName Version | ${Platform.operatingSystemVersion} |\n'
|
|
||||||
'| Resolution | ${physW}x$physH px'
|
|
||||||
' (logical: ${size.width.toInt()}x${size.height.toInt()} pt,'
|
|
||||||
' ratio: ${pixelRatio.toStringAsFixed(1)}x) |\n'
|
|
||||||
'| Dart Version | ${Platform.version.split(' ').first} |\n'
|
|
||||||
'| Processors | ${Platform.numberOfProcessors} |\n'
|
|
||||||
'| Dark Mode | ${isDark ? 'yes' : 'no'} |\n'
|
|
||||||
'| IMAP Accounts | $imapCount |\n'
|
|
||||||
'| JMAP Accounts | $jmapCount |\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
static String _capitalize(String s) =>
|
|
||||||
s.isEmpty ? s : '${s[0].toUpperCase()}${s.substring(1)}';
|
|
||||||
|
|
||||||
Future<void> _copyToClipboard(
|
Future<void> _copyToClipboard(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
int imapCount,
|
int imapCount,
|
||||||
@@ -79,10 +38,17 @@ class _AboutScreenState extends ConsumerState<AboutScreen> {
|
|||||||
try {
|
try {
|
||||||
pkg = await _packageInfoFuture;
|
pkg = await _packageInfoFuture;
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
final androidInfo = await _androidInfoFuture;
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
await Clipboard.setData(
|
await Clipboard.setData(
|
||||||
ClipboardData(
|
ClipboardData(
|
||||||
text: _buildMarkdown(context, pkg, imapCount, jmapCount),
|
text: buildAboutMarkdown(
|
||||||
|
context: context,
|
||||||
|
pkg: pkg,
|
||||||
|
imapCount: imapCount,
|
||||||
|
jmapCount: jmapCount,
|
||||||
|
androidInfo: androidInfo,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
@@ -104,9 +70,16 @@ class _AboutScreenState extends ConsumerState<AboutScreen> {
|
|||||||
try {
|
try {
|
||||||
pkg = await _packageInfoFuture;
|
pkg = await _packageInfoFuture;
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
final androidInfo = await _androidInfoFuture;
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
final body = Uri.encodeComponent(
|
final body = Uri.encodeComponent(
|
||||||
_buildMarkdown(context, pkg, imapCount, jmapCount),
|
buildAboutMarkdown(
|
||||||
|
context: context,
|
||||||
|
pkg: pkg,
|
||||||
|
imapCount: imapCount,
|
||||||
|
jmapCount: jmapCount,
|
||||||
|
androidInfo: androidInfo,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
final url = Uri.parse(
|
final url = Uri.parse(
|
||||||
'https://codeberg.org/guettli/sharedinbox/issues/new?body=$body',
|
'https://codeberg.org/guettli/sharedinbox/issues/new?body=$body',
|
||||||
@@ -156,23 +129,29 @@ class _AboutScreenState extends ConsumerState<AboutScreen> {
|
|||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
return Markdown(
|
return FutureBuilder<AndroidDeviceInfo?>(
|
||||||
data: _buildMarkdown(
|
future: _androidInfoFuture,
|
||||||
context,
|
builder: (context, androidSnapshot) {
|
||||||
snapshot.data,
|
return Markdown(
|
||||||
imapCount,
|
data: buildAboutMarkdown(
|
||||||
jmapCount,
|
context: context,
|
||||||
),
|
pkg: snapshot.data,
|
||||||
selectable: true,
|
imapCount: imapCount,
|
||||||
onTapLink: (text, href, title) {
|
jmapCount: jmapCount,
|
||||||
if (href != null) {
|
androidInfo: androidSnapshot.data,
|
||||||
unawaited(
|
),
|
||||||
launchUrl(
|
selectable: true,
|
||||||
Uri.parse(href),
|
onTapLink: (text, href, title) {
|
||||||
mode: LaunchMode.externalApplication,
|
if (href != null) {
|
||||||
),
|
unawaited(
|
||||||
);
|
launchUrl(
|
||||||
}
|
Uri.parse(href),
|
||||||
|
mode: LaunchMode.externalApplication,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
|
||||||
|
import 'package:sharedinbox/core/models/account.dart';
|
||||||
import 'package:sharedinbox/core/repositories/sync_log_repository.dart';
|
import 'package:sharedinbox/core/repositories/sync_log_repository.dart';
|
||||||
import 'package:sharedinbox/di.dart';
|
import 'package:sharedinbox/di.dart';
|
||||||
|
import 'package:sharedinbox/ui/utils/about_markdown.dart';
|
||||||
|
|
||||||
final _timeFmt = DateFormat('MMM d, HH:mm:ss');
|
final _timeFmt = DateFormat('MMM d, HH:mm:ss');
|
||||||
|
|
||||||
@@ -21,6 +25,57 @@ String _fmtBytes(int bytes) {
|
|||||||
return '${(bytes / (1024 * 1024)).toStringAsFixed(1)} MB';
|
return '${(bytes / (1024 * 1024)).toStringAsFixed(1)} MB';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _buildSyncEntryMarkdown(SyncLogEntry entry) {
|
||||||
|
final buf = StringBuffer();
|
||||||
|
buf.writeln('## Sync Entry');
|
||||||
|
buf.writeln();
|
||||||
|
buf.writeln('| Property | Value |');
|
||||||
|
buf.writeln('|----------|-------|');
|
||||||
|
buf.writeln('| Started | ${_timeFmt.format(entry.startedAt)} |');
|
||||||
|
buf.writeln('| Finished | ${_timeFmt.format(entry.finishedAt)} |');
|
||||||
|
buf.writeln('| Duration | ${_fmtDuration(entry.duration)} |');
|
||||||
|
if (entry.protocol.isNotEmpty) {
|
||||||
|
buf.writeln('| Protocol | ${entry.protocol.toUpperCase()} |');
|
||||||
|
}
|
||||||
|
final statusLabel = entry.isOk
|
||||||
|
? 'OK'
|
||||||
|
: entry.isPermanent
|
||||||
|
? 'Error (permanent)'
|
||||||
|
: 'Error';
|
||||||
|
buf.writeln('| Status | $statusLabel |');
|
||||||
|
buf.writeln('| Emails fetched | ${entry.emailsFetched} |');
|
||||||
|
buf.writeln('| Emails up-to-date | ${entry.emailsSkipped} |');
|
||||||
|
buf.writeln('| Mailboxes synced | ${entry.mailboxesSynced} |');
|
||||||
|
buf.writeln('| Pending changes flushed | ${entry.pendingFlushed} |');
|
||||||
|
buf.writeln('| Data transferred | ${_fmtBytes(entry.bytesTransferred)} |');
|
||||||
|
if (entry.mailboxStats.isNotEmpty) {
|
||||||
|
buf.writeln();
|
||||||
|
buf.writeln('### Per mailbox');
|
||||||
|
buf.writeln();
|
||||||
|
buf.writeln('| Mailbox | Fetched | Up-to-date | Duration |');
|
||||||
|
buf.writeln('|---------|---------|------------|----------|');
|
||||||
|
for (final m in entry.mailboxStats) {
|
||||||
|
final dur = m.duration != null ? _fmtDuration(m.duration!) : '-';
|
||||||
|
buf.writeln('| ${m.mailboxPath} | ${m.fetched} | ${m.skipped} | $dur |');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entry.errorMessage != null) {
|
||||||
|
buf.writeln();
|
||||||
|
buf.writeln('**Error:**');
|
||||||
|
buf.writeln();
|
||||||
|
buf.writeln(entry.errorMessage);
|
||||||
|
}
|
||||||
|
if (entry.stackTrace != null) {
|
||||||
|
buf.writeln();
|
||||||
|
buf.writeln('**Stack trace:**');
|
||||||
|
buf.writeln();
|
||||||
|
buf.writeln('```');
|
||||||
|
buf.write(entry.stackTrace);
|
||||||
|
buf.writeln('```');
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
class SyncLogScreen extends ConsumerStatefulWidget {
|
class SyncLogScreen extends ConsumerStatefulWidget {
|
||||||
const SyncLogScreen({super.key, required this.accountId});
|
const SyncLogScreen({super.key, required this.accountId});
|
||||||
|
|
||||||
@@ -69,6 +124,41 @@ class _SyncLogScreenState extends ConsumerState<SyncLogScreen> {
|
|||||||
ref.read(syncManagerProvider).syncNow(widget.accountId);
|
ref.read(syncManagerProvider).syncNow(widget.accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _copyEntry(SyncLogEntry entry, BuildContext context) async {
|
||||||
|
final accounts =
|
||||||
|
await ref.read(accountRepositoryProvider).observeAccounts().first;
|
||||||
|
final imapCount = accounts.where((a) => a.type == AccountType.imap).length;
|
||||||
|
final jmapCount = accounts.where((a) => a.type == AccountType.jmap).length;
|
||||||
|
|
||||||
|
PackageInfo? pkg;
|
||||||
|
try {
|
||||||
|
pkg = await PackageInfo.fromPlatform();
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
|
final androidInfo = await getAndroidDeviceInfo();
|
||||||
|
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
|
final syncMd = _buildSyncEntryMarkdown(entry);
|
||||||
|
final aboutMd = buildAboutMarkdown(
|
||||||
|
context: context,
|
||||||
|
pkg: pkg,
|
||||||
|
imapCount: imapCount,
|
||||||
|
jmapCount: jmapCount,
|
||||||
|
androidInfo: androidInfo,
|
||||||
|
);
|
||||||
|
await Clipboard.setData(ClipboardData(text: '$syncMd\n$aboutMd'));
|
||||||
|
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
duration: Duration(seconds: 3),
|
||||||
|
content: Text('Copied to clipboard'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -96,16 +186,20 @@ class _SyncLogScreenState extends ConsumerState<SyncLogScreen> {
|
|||||||
? const Center(child: Text('No sync entries yet'))
|
? const Center(child: Text('No sync entries yet'))
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
itemCount: _entries.length,
|
itemCount: _entries.length,
|
||||||
itemBuilder: (ctx, i) => _SyncLogTile(entry: _entries[i]),
|
itemBuilder: (ctx, i) => _SyncLogTile(
|
||||||
|
entry: _entries[i],
|
||||||
|
onCopy: () => _copyEntry(_entries[i], ctx),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SyncLogTile extends StatelessWidget {
|
class _SyncLogTile extends StatelessWidget {
|
||||||
const _SyncLogTile({required this.entry});
|
const _SyncLogTile({required this.entry, required this.onCopy});
|
||||||
|
|
||||||
final SyncLogEntry entry;
|
final SyncLogEntry entry;
|
||||||
|
final VoidCallback onCopy;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -115,6 +209,12 @@ class _SyncLogTile extends StatelessWidget {
|
|||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final errorColor = theme.colorScheme.error;
|
final errorColor = theme.colorScheme.error;
|
||||||
|
|
||||||
|
final subtitleText = entry.isOk
|
||||||
|
? '${entry.emailsFetched} new · ${entry.emailsSkipped} up-to-date · took $durationLabel'
|
||||||
|
: entry.isPermanent
|
||||||
|
? 'Error (permanent) · took $durationLabel'
|
||||||
|
: 'Error · took $durationLabel';
|
||||||
|
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
leading: Icon(
|
leading: Icon(
|
||||||
entry.isOk ? Icons.check_circle : Icons.error_outline,
|
entry.isOk ? Icons.check_circle : Icons.error_outline,
|
||||||
@@ -125,11 +225,20 @@ class _SyncLogTile extends StatelessWidget {
|
|||||||
style: entry.isOk ? null : TextStyle(color: errorColor),
|
style: entry.isOk ? null : TextStyle(color: errorColor),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
entry.isOk
|
subtitleText,
|
||||||
? '${entry.emailsFetched} new · ${entry.emailsSkipped} up-to-date · took $durationLabel'
|
|
||||||
: 'Error · took $durationLabel',
|
|
||||||
style: TextStyle(fontSize: 12, color: entry.isOk ? null : errorColor),
|
style: TextStyle(fontSize: 12, color: entry.isOk ? null : errorColor),
|
||||||
),
|
),
|
||||||
|
trailing: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.copy, size: 18),
|
||||||
|
tooltip: 'Copy as markdown',
|
||||||
|
onPressed: onCopy,
|
||||||
|
),
|
||||||
|
const Icon(Icons.expand_more),
|
||||||
|
],
|
||||||
|
),
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(72, 0, 16, 12),
|
padding: const EdgeInsets.fromLTRB(72, 0, 16, 12),
|
||||||
@@ -171,6 +280,31 @@ class _SyncLogTile extends StatelessWidget {
|
|||||||
style: TextStyle(color: errorColor, fontSize: 12),
|
style: TextStyle(color: errorColor, fontSize: 12),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (entry.stackTrace != null) ...[
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.only(top: 6, bottom: 2),
|
||||||
|
child: Text(
|
||||||
|
'Stack trace',
|
||||||
|
style: TextStyle(fontSize: 12, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.black87,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
entry.stackTrace!,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
fontFamily: 'monospace',
|
||||||
|
color: Colors.red[300],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
if (entry.protocolLog != null) ...[
|
if (entry.protocolLog != null) ...[
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.only(top: 6, bottom: 2),
|
padding: EdgeInsets.only(top: 6, bottom: 2),
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
|
||||||
|
const _gitHash = String.fromEnvironment('GIT_HASH');
|
||||||
|
|
||||||
|
/// Builds the About markdown table used in [AboutScreen] and sync log copies.
|
||||||
|
///
|
||||||
|
/// Pass [androidInfo] when running on Android; omit on other platforms.
|
||||||
|
String buildAboutMarkdown({
|
||||||
|
required BuildContext context,
|
||||||
|
PackageInfo? pkg,
|
||||||
|
required int imapCount,
|
||||||
|
required int jmapCount,
|
||||||
|
AndroidDeviceInfo? androidInfo,
|
||||||
|
}) {
|
||||||
|
final size = MediaQuery.of(context).size;
|
||||||
|
final pixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||||
|
final physW = (size.width * pixelRatio).toInt();
|
||||||
|
final physH = (size.height * pixelRatio).toInt();
|
||||||
|
final version = pkg != null ? '${pkg.version}+${pkg.buildNumber}' : 'unknown';
|
||||||
|
final versionDisplay = _gitHash.isNotEmpty
|
||||||
|
? '[$version](https://codeberg.org/guettli/sharedinbox/commit/$_gitHash)'
|
||||||
|
: version;
|
||||||
|
final osName = _capitalize(Platform.operatingSystem);
|
||||||
|
final isDark = MediaQuery.of(context).platformBrightness == Brightness.dark;
|
||||||
|
|
||||||
|
final gitCommitLine = _gitHash.isNotEmpty
|
||||||
|
? '| Git Commit | [$_gitHash](https://codeberg.org/guettli/sharedinbox/commit/$_gitHash) |\n'
|
||||||
|
: '';
|
||||||
|
final androidLines = androidInfo != null
|
||||||
|
? '| Android Manufacturer | ${androidInfo.manufacturer} |\n'
|
||||||
|
'| Android Model | ${androidInfo.model} |\n'
|
||||||
|
'| Android Version | ${androidInfo.version.release} |\n'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
return '## [sharedinbox.de](https://sharedinbox.de)\n\n'
|
||||||
|
'| Property | Value |\n'
|
||||||
|
'|----------|-------|\n'
|
||||||
|
'| App Version | $versionDisplay |\n'
|
||||||
|
'$gitCommitLine'
|
||||||
|
'| Platform | ${Platform.operatingSystem} |\n'
|
||||||
|
'| $osName Version | ${Platform.operatingSystemVersion} |\n'
|
||||||
|
'$androidLines'
|
||||||
|
'| Resolution | ${physW}x$physH px'
|
||||||
|
' (logical: ${size.width.toInt()}x${size.height.toInt()} pt,'
|
||||||
|
' ratio: ${pixelRatio.toStringAsFixed(1)}x) |\n'
|
||||||
|
'| Dart Version | ${Platform.version.split(' ').first} |\n'
|
||||||
|
'| Processors | ${Platform.numberOfProcessors} |\n'
|
||||||
|
'| Dark Mode | ${isDark ? 'yes' : 'no'} |\n'
|
||||||
|
'| IMAP Accounts | $imapCount |\n'
|
||||||
|
'| JMAP Accounts | $jmapCount |\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetches Android device info, or null on non-Android platforms.
|
||||||
|
Future<AndroidDeviceInfo?> getAndroidDeviceInfo() async {
|
||||||
|
if (!Platform.isAndroid) return null;
|
||||||
|
try {
|
||||||
|
return await DeviceInfoPlugin().androidInfo;
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _capitalize(String s) =>
|
||||||
|
s.isEmpty ? s : '${s[0].toUpperCase()}${s.substring(1)}';
|
||||||
@@ -249,6 +249,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.12"
|
version: "0.7.12"
|
||||||
|
device_info_plus:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: device_info_plus
|
||||||
|
sha256: "6a642e1daa10190af89ba6cb6386c0df7d071a3592080bfe1e44faa63ae1df65"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "13.1.0"
|
||||||
|
device_info_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_platform_interface
|
||||||
|
sha256: "04b173a92e2d9161dfead145667037c8d834db725ce2e7b942bfe18fd2f45a46"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "8.1.0"
|
||||||
drift:
|
drift:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -1284,6 +1300,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.3.0"
|
version: "6.3.0"
|
||||||
|
win32_registry:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: win32_registry
|
||||||
|
sha256: "73b1d78920a9d6e03f8b4e43e612b87bf3152a0e5c5e5150267762b7c4116904"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.3"
|
||||||
workmanager:
|
workmanager:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ dependencies:
|
|||||||
package_info_plus: ^10.1.0
|
package_info_plus: ^10.1.0
|
||||||
share_plus: ^13.1.0
|
share_plus: ^13.1.0
|
||||||
|
|
||||||
|
# Device hardware info for bug reports
|
||||||
|
device_info_plus: ^13.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ const _excluded = {
|
|||||||
'lib/ui/widgets/try_connection_button.dart',
|
'lib/ui/widgets/try_connection_button.dart',
|
||||||
'lib/ui/widgets/undo_shell.dart',
|
'lib/ui/widgets/undo_shell.dart',
|
||||||
'lib/ui/screens/about_screen.dart',
|
'lib/ui/screens/about_screen.dart',
|
||||||
|
'lib/ui/utils/about_markdown.dart',
|
||||||
'lib/ui/widgets/email_tile.dart',
|
'lib/ui/widgets/email_tile.dart',
|
||||||
'lib/core/sync/account_sync_manager.dart',
|
'lib/core/sync/account_sync_manager.dart',
|
||||||
'lib/core/sync/background_sync.dart',
|
'lib/core/sync/background_sync.dart',
|
||||||
|
|||||||
@@ -288,6 +288,8 @@ class _FakeLogs implements SyncLogRepository {
|
|||||||
required String accountId,
|
required String accountId,
|
||||||
required bool success,
|
required bool success,
|
||||||
String? errorMessage,
|
String? errorMessage,
|
||||||
|
String? stackTrace,
|
||||||
|
bool isPermanent = false,
|
||||||
required String protocol,
|
required String protocol,
|
||||||
required int emailsFetched,
|
required int emailsFetched,
|
||||||
required int emailsSkipped,
|
required int emailsSkipped,
|
||||||
|
|||||||
@@ -181,6 +181,8 @@ class FakeSyncLogRepository implements SyncLogRepository {
|
|||||||
required String accountId,
|
required String accountId,
|
||||||
required bool success,
|
required bool success,
|
||||||
String? errorMessage,
|
String? errorMessage,
|
||||||
|
String? stackTrace,
|
||||||
|
bool isPermanent = false,
|
||||||
required String protocol,
|
required String protocol,
|
||||||
required int emailsFetched,
|
required int emailsFetched,
|
||||||
required int emailsSkipped,
|
required int emailsSkipped,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ void main() {
|
|||||||
group('Migration', () {
|
group('Migration', () {
|
||||||
test('schemaVersion matches expected value', () async {
|
test('schemaVersion matches expected value', () async {
|
||||||
final db = AppDatabase(NativeDatabase.memory());
|
final db = AppDatabase(NativeDatabase.memory());
|
||||||
expect(db.schemaVersion, 32);
|
expect(db.schemaVersion, 33);
|
||||||
await db.close();
|
await db.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -194,6 +194,11 @@ void main() {
|
|||||||
// v32: local_sieve_applied table.
|
// v32: local_sieve_applied table.
|
||||||
await db.customSelect('SELECT count(*) FROM local_sieve_applied').get();
|
await db.customSelect('SELECT count(*) FROM local_sieve_applied').get();
|
||||||
|
|
||||||
|
// v33: error_stack_trace and is_permanent columns on sync_logs.
|
||||||
|
final syncLogColumns = await _tableColumns(db, 'sync_logs');
|
||||||
|
expect(syncLogColumns, contains('error_stack_trace'));
|
||||||
|
expect(syncLogColumns, contains('is_permanent'));
|
||||||
|
|
||||||
await db.close();
|
await db.close();
|
||||||
if (dbFile.existsSync()) dbFile.deleteSync();
|
if (dbFile.existsSync()) dbFile.deleteSync();
|
||||||
});
|
});
|
||||||
@@ -381,11 +386,16 @@ void main() {
|
|||||||
await _tableColumns(db, 'sync_log_mailboxes');
|
await _tableColumns(db, 'sync_log_mailboxes');
|
||||||
expect(syncLogMailboxColumns, contains('duration_ms'));
|
expect(syncLogMailboxColumns, contains('duration_ms'));
|
||||||
|
|
||||||
|
// v33: error_stack_trace and is_permanent columns on sync_logs.
|
||||||
|
final syncLogColumns = await _tableColumns(db, 'sync_logs');
|
||||||
|
expect(syncLogColumns, contains('error_stack_trace'));
|
||||||
|
expect(syncLogColumns, contains('is_permanent'));
|
||||||
|
|
||||||
await db.close();
|
await db.close();
|
||||||
if (dbFile.existsSync()) dbFile.deleteSync();
|
if (dbFile.existsSync()) dbFile.deleteSync();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fresh install creates all tables at schemaVersion 32', () async {
|
test('fresh install creates all tables at schemaVersion 33', () async {
|
||||||
final db = AppDatabase(NativeDatabase.memory());
|
final db = AppDatabase(NativeDatabase.memory());
|
||||||
await db.select(db.accounts).get();
|
await db.select(db.accounts).get();
|
||||||
|
|
||||||
@@ -426,6 +436,11 @@ void main() {
|
|||||||
await _tableColumns(db, 'sync_log_mailboxes');
|
await _tableColumns(db, 'sync_log_mailboxes');
|
||||||
expect(syncLogMailboxColumns, contains('duration_ms'));
|
expect(syncLogMailboxColumns, contains('duration_ms'));
|
||||||
|
|
||||||
|
// v33: error_stack_trace and is_permanent columns on sync_logs.
|
||||||
|
final syncLogColumns = await _tableColumns(db, 'sync_logs');
|
||||||
|
expect(syncLogColumns, contains('error_stack_trace'));
|
||||||
|
expect(syncLogColumns, contains('is_permanent'));
|
||||||
|
|
||||||
await db.close();
|
await db.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -170,6 +170,8 @@ class _FakeSyncLog implements SyncLogRepository {
|
|||||||
required String accountId,
|
required String accountId,
|
||||||
required bool success,
|
required bool success,
|
||||||
String? errorMessage,
|
String? errorMessage,
|
||||||
|
String? stackTrace,
|
||||||
|
bool isPermanent = false,
|
||||||
required String protocol,
|
required String protocol,
|
||||||
required int emailsFetched,
|
required int emailsFetched,
|
||||||
required int emailsSkipped,
|
required int emailsSkipped,
|
||||||
|
|||||||
@@ -126,4 +126,34 @@ void main() {
|
|||||||
expect(rows.first.result, 'error');
|
expect(rows.first.result, 'error');
|
||||||
expect(rows.first.errorMessage, 'Connection refused');
|
expect(rows.first.errorMessage, 'Connection refused');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('stores and retrieves stackTrace and isPermanent on error entries',
|
||||||
|
() async {
|
||||||
|
final repo = SyncLogRepositoryImpl(db);
|
||||||
|
final start = DateTime(2024, 3, 1, 9);
|
||||||
|
final end = DateTime(2024, 3, 1, 9, 0, 1);
|
||||||
|
const fakeTrace = '#0 main (file:///app/lib/main.dart:10:5)';
|
||||||
|
|
||||||
|
await repo.log(
|
||||||
|
accountId: 'acc1',
|
||||||
|
success: false,
|
||||||
|
errorMessage: 'MissingPluginException',
|
||||||
|
stackTrace: fakeTrace,
|
||||||
|
isPermanent: true,
|
||||||
|
protocol: 'imap',
|
||||||
|
emailsFetched: 0,
|
||||||
|
emailsSkipped: 0,
|
||||||
|
mailboxesSynced: 0,
|
||||||
|
pendingFlushed: 0,
|
||||||
|
bytesTransferred: 0,
|
||||||
|
startedAt: start,
|
||||||
|
finishedAt: end,
|
||||||
|
);
|
||||||
|
|
||||||
|
final entries = await repo.observeSyncLogs('acc1').first;
|
||||||
|
final entry = entries.firstWhere((e) => e.startedAt == start);
|
||||||
|
expect(entry.stackTrace, fakeTrace);
|
||||||
|
expect(entry.isPermanent, true);
|
||||||
|
expect(entry.errorMessage, 'MissingPluginException');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user