fixed pending share race error on warm app start

This commit is contained in:
2026-07-02 15:28:05 +02:00
parent 4bc7ffd37a
commit 32f7c311bc
9 changed files with 125 additions and 9 deletions
+13 -1
View File
@@ -187,11 +187,23 @@ class _FilesUploadDialogState extends State<FilesUploadDialog> {
'${_uploadableFiles.indexOf(file) + 1}/${_uploadableFiles.length}';
});
// A vanished source file would otherwise surface as a cryptic
// "Content-Length must contain only digits" HttpException, because
// statSync reports size -1 for missing files.
final fileStat = FileStat.statSync(filePath);
if (fileStat.type == FileSystemEntityType.notFound || fileStat.size < 0) {
_showUploadError(
'Die Datei "$fileName" ist nicht mehr verfügbar. '
'Bitte wähle sie erneut aus.',
);
return;
}
final HttpClientResponse uploadTask;
try {
uploadTask = await webdavClient.putFile(
File(filePath),
FileStat.statSync(filePath),
fileStat,
PathUri.parse(fullRemotePath),
onProgress: (progress) {
setState(() {
@@ -197,7 +197,7 @@ void _setExternalDraftAndOpenChat(
final settings = context.read<SettingsCubit>();
settings.val(write: true).talkSettings.drafts[room.token] = share.text!;
}
ShareIntentListener.instance.clear();
ShareIntentListener.instance.clear(ifCurrent: share);
_finishWithChat(context, room);
}
@@ -212,13 +212,18 @@ Future<void> _externalUploadFlow(
screen: FilesUploadDialog(
filePaths: share.filePaths,
remotePath: targetPath.join('/'),
onUploadFinished: (_) => _afterExternalUploaded(context, targetPath),
onUploadFinished: (_) =>
_afterExternalUploaded(context, targetPath, share),
),
);
}
void _afterExternalUploaded(BuildContext context, List<String> targetPath) {
ShareIntentListener.instance.clear();
void _afterExternalUploaded(
BuildContext context,
List<String> targetPath,
PendingShare share,
) {
ShareIntentListener.instance.clear(ifCurrent: share);
if (!context.mounted) return;
_finishWithFolder(context, targetPath);
}
@@ -40,7 +40,7 @@ class ShareTargetPage extends StatelessWidget {
@override
Widget build(BuildContext context) => PopScope(
onPopInvokedWithResult: (didPop, _) {
if (didPop) ShareIntentListener.instance.clear();
if (didPop) ShareIntentListener.instance.clear(ifCurrent: share);
},
child: Scaffold(
appBar: AppBar(title: Text(_appBarTitle())),