From be77d91e9110697c6874ecf9a06804ed98e815d1 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Tue, 9 Feb 2021 19:45:43 +0100 Subject: [PATCH] change draft attachment directory (#2070) --- .../tusky/components/drafts/DraftHelper.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftHelper.kt b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftHelper.kt index 5328fef70..5038ac00c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftHelper.kt @@ -59,13 +59,19 @@ class DraftHelper @Inject constructor( ): Completable { return Single.fromCallable { - val draftDirectory = context.getExternalFilesDir("Tusky") + val externalFilesDir = context.getExternalFilesDir("Tusky") - if (draftDirectory == null || !(draftDirectory.exists())) { + if (externalFilesDir == null || !(externalFilesDir.exists())) { Log.e("DraftHelper", "Error obtaining directory to save media.") throw Exception() } + val draftDirectory = File(externalFilesDir, "Drafts") + + if (!draftDirectory.exists()) { + draftDirectory.mkdir() + } + val uris = mediaUris.map { uriString -> uriString.toUri() }.map { uri ->