1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00

Create empty file in marker directory (fixes #1249) (#1490)

* Create empty file in marker directory (fixes #1249)

HTH

* wip
This commit is contained in:
Jakob Borg 2020-04-02 17:48:28 +02:00 committed by GitHub
parent dd6f0a50a1
commit 72c6dfb8d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -462,18 +462,20 @@ public class FolderActivity extends SyncthingActivity
return true; return true;
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
mFolderUri != null && mFolderUri != null) {
mFolder.type.equals(Constants.FOLDER_TYPE_SEND_ONLY)) {
/** /**
* Normally, syncthing takes care of creating the ".stfolder" marker. * Normally, syncthing takes care of creating the ".stfolder" marker.
* This fails on newer android versions if the syncthing binary only has * This fails on newer android versions if the syncthing binary only has
* readonly access on the path and the user tries to configure a * 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. * 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); DocumentFile dfFolder = DocumentFile.fromTreeUri(this, mFolderUri);
if (dfFolder != null) { if (dfFolder != null) {
Log.v(TAG, "Creating new directory " + mFolder.path + File.separator + FOLDER_MARKER_NAME); 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); getApi().createFolder(mFolder);