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) HTH * wip
This commit is contained in:
parent
dd6f0a50a1
commit
72c6dfb8d0
1 changed files with 5 additions and 3 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue