From 32a88ab89027248c82512c821fb08df05464db75 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 25 Jan 2025 07:57:01 +0530 Subject: [PATCH] Truncate existing file in export --- .../local/subscription/workers/SubscriptionExportWorker.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/workers/SubscriptionExportWorker.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/workers/SubscriptionExportWorker.kt index a124fc666..6de91f174 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/workers/SubscriptionExportWorker.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/workers/SubscriptionExportWorker.kt @@ -46,7 +46,8 @@ class SubscriptionExportWorker( setForeground(createForegroundInfo(title)) withContext(Dispatchers.IO) { - applicationContext.contentResolver.openOutputStream(uri)?.use { + // Truncate file if it already exists + applicationContext.contentResolver.openOutputStream(uri, "wt")?.use { ImportExportJsonHelper.writeTo(subscriptions, it) } }