multiple runtime bugfixes for 1.5.5+65

This commit is contained in:
2026-08-28 20:42:30 +02:00
parent 65300614b1
commit 71839d0848
18 changed files with 344 additions and 159 deletions
@@ -1,10 +1,35 @@
import 'package:nextcloud/nextcloud.dart';
import '../files_sharing/file_sharing_api.dart';
import '../files_sharing/file_sharing_api_params.dart';
import '../webdav/webdav_api.dart';
/// WebDAV folder under which Talk-shared files are uploaded before being
/// linked into a chat.
const String talkShareFolder = 'MarianumMobile';
Future<void>? _shareFolderReady;
/// Creates [talkShareFolder] if it is missing, at most once per session — the
/// folder is permanent, so every later upload would just pay a round trip to
/// be told it already exists (WebDAV answers MKCOL on an existing collection
/// with 405, which is the normal case here and must not surface as an error).
Future<void> ensureTalkShareFolder() =>
_shareFolderReady ??= _createTalkShareFolder();
Future<void> _createTalkShareFolder() async {
try {
final webdav = await WebdavApi.webdav;
await webdav.mkcol(PathUri.parse('/$talkShareFolder'));
} on DynamiteApiException catch (e) {
// Anything but "already exists" leaves the folder unconfirmed, so the next
// upload has to try again.
if (e.statusCode != 405) _shareFolderReady = null;
} catch (_) {
_shareFolderReady = null;
}
}
/// Posts each already-uploaded WebDAV path as a Talk share (ShareType 10) to
/// the given conversation token. Calls run concurrently — the server accepts
/// parallel posts and the picker UI is blocked anyway, so we shouldn't pay