From 72c6dfb8d0cabb5735684714787b21b0de66f2e6 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 2 Apr 2020 17:48:28 +0200 Subject: [PATCH] Create empty file in marker directory (fixes #1249) (#1490) * Create empty file in marker directory (fixes #1249) HTH * wip --- .../syncthingandroid/activities/FolderActivity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java index b3952ecc..af512d49 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java @@ -462,18 +462,20 @@ public class FolderActivity extends SyncthingActivity return true; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && - mFolderUri != null && - mFolder.type.equals(Constants.FOLDER_TYPE_SEND_ONLY)) { + mFolderUri != null) { /** * Normally, syncthing takes care of creating the ".stfolder" marker. * This fails on newer android versions if the syncthing binary only has * readonly access on the path and the user tries to configure a * sendonly folder. To fix this, we'll precreate the marker using java code. + * We also create an empty file in the marker directory, to hopefully keep + * it alive in the face of overzealous disk cleaner apps. */ DocumentFile dfFolder = DocumentFile.fromTreeUri(this, mFolderUri); if (dfFolder != null) { Log.v(TAG, "Creating new directory " + mFolder.path + File.separator + FOLDER_MARKER_NAME); - dfFolder.createDirectory(FOLDER_MARKER_NAME); + DocumentFile marker = dfFolder.createDirectory(FOLDER_MARKER_NAME); + marker.createFile("text/plain", "empty"); } } getApi().createFolder(mFolder);