Some Android distributions, like MIUI, have built-in filesystem cleaner that clean up trash from various locations. Common feature of it is to remove empty directories. I've run into issue where Xiaomi MIUI's Cleaner removed .stfolder rendering syncthing not working. I had to manually add some random, non-empty file there to prevent it from happening again.
It would be nice to have an option in Syncthing for Android to create any non-empty file in .stfolder for the sake of cleaners.
I would make the workaround default when Xiaomi MIUI ist detected.
There's a handful of other things that can remove it too, like SDMaid that is quite popular on all of Android distributions.
Maybe make it a global default would be the way to go?
Sorry, but it's a problem of the distribution/apps that you use, not syncthing.
You have a workaround , and I don't we should add band aids for someone elses unwise decisions.
Would it cause technical problems if we'd fill in a text file with random content below the .stfolder ?
It wouldn't but fundamentally it's the wrong thing todo, as it's just some cleaning someone elses mess.
The user can already work around this.
Yes and no, to be honest. On MIUI the cleaner is a self enforcing system app. It can be deleted but on some MIUI versions, it soft bricks the phone and wipes your data while recovering it. I understand the strategical reason, but we can't always say "it's Android problem syncthing is not the right point to fix this". Users want to use syncthing on Android and yes, that's third party fault.
I agree with @Catfriend1 here. It's dirty, but Android does dirty things and if we want to play in that ecosystem I think we just need to put on the hazmat suit and get down with it. It would hardly be the first ugly hack to workaround weirdness on Android.
This one has the advantage that you can do it entirely in the App and I don't need to care, too. ;)
It's not like a echo 'I am a hack' > .stfolder/android.txt will kill us.
(For illustrative purposes only. Please don't implement as a shell script.)
I'll see what I can do, but maybe I need to use the shell to create the file so it works properly on internal and external storage paths. External storage paths are ugly to handle because of SAF Tokens you need to grab first in the Java world before you can write to the paths.
Anyone having the same issue reading this? I've put up a test APK at https://drive.google.com/open?id=1FyPl16VXL6WAjuazSDIBtaN79ZRCTX0o and would appreciate feedback if this works correctly after adding a new folder and running the phone's file cleanup utility. The workaround adds a dummy text file below the ".stfolder" directory.
@NicoWeio @slashbeast
Hi,
Any option to have this feature added? It's a real problem from end user point of view, that one needs to manually make .stfolder non-empty on MIUI devices, or in fact any other Android device that runs cleaning software (like SDMaid).
The only option is to write the code that does it, or wait and hope that someone that cares about this issue and is capable does that for you.
@Catfriend1 above written the code as I see he have test APK for that. Can it be merged with mainline Syncthing?
Sure, someone needs to create a PR.
Sorry, but it's a problem of the distribution/apps that you use, not syncthing.
You have a workaround , and I don't we should add band aids for someone elses unwise decisions.
It's been a year and the problem still persist. It's a simple one line of code to fix this problem. Yet you choose to ignore it on the basis of "it's your platform's problem". Good job @AudriusButkevicius.
And your comment obviously provides amazing insights and value that we have not had before.
You could have written that one line of code oppose to waste time on the comment.
It's not easy to find this issue so many user who has bricked syncthing on their phone can't add their complaint here. "Folder marker missing" is the error what they see throw theirs tears when synctihn stopped works so I place this here for google. It's really existing fatal problem for many users (Xiaomi has 8% of world market and their cleaner is built in function - very good function for almost everything - and you can't disable/make except to not delete empty directory). I'm not using syncthing very often because of this so often because in busy time there's no time to debugging errors and no time to delete and again building synced directory. But now I see what stupid problem is this. Please do the ugly thing and place there the file.
It sounds very offense... But it's not us but the manufacturer to blame for deleting the file. Thats a fact. You could file a PR if you'd like also to offer help instead of getting tears . In parallel, please tell xiaomi that you are unhappy with their android mod.
Or we could revert the type from directory to file in Syncthing proper, as we anyway don鈥檛 store anything there nor apparently plan to.
I think we should keep it as a folder, for future proofing if anything, because we'll have to do the conversion dance yet again.
This literally needs a 2 line PR for someone who gives a duck about Xiaomi, which sadly I don't.
The discussion is reaching the point where I will make an attempt at fixing it, using just the GitHub editor and zero testing.
I do not quire understand what is the background for this antagonism coming from all the parties here. On one end there is this extreme purism, where Syncthing will not support a vendor quirks, on another there's whole Xiaomi lineup that has cleaner integrated that remove empty directories. However, cleaners are not really limited to Xiaomi, people uses it on all kind of devices, so it's more about recognition of the fact that using empty directory as a vital part of the syncthing may lead to issues on some end-users deployments.
Hmm. Sidenote, the cleaner can also be uninstalled (without root). Source https://www.fonearena.com/blog/275578/how-to-uninstall-apps-on-xiaomi-without-root.html suggests...
# Mi Cleaner
adb shell pm uninstall -k --user 0 com.miui.cleanmaster
# Mi Recycle
adb shell pm uninstall -k --user 0 com.xiaomi.mirecycle
Good source: https://devcondition.com/article/removing-unneeded-miui-applications/
Going back as to define what problem we have here.
Syncthing depends on the existence of empty directory .stfolder, if it's missing, the error message does not describe the problem beside that something is wrong, rendering Syncthing not working for given shares.
Do this really need a if-o-logic to be only for Xiaomi? Sooner or later other people who uses things like SDMaid or other software to cleanup and tidy around Android will report issue, that Syncthing randomly failsx.
The error says that the folder has disappeared, why it disappeared, it can't tell.
@hever @slashbeast
Could you two please help confirm if the issue is fixed in this (test) build:
https://build.syncthing.net/repository/download/SyncthingAndroid_Build/59661:id/apk/debug/app-debug.apk
If so, we'll approve the PR to let the fix land in a future release of the app.
@Catfriend1 I tested it for cleanup scenario and now it's good. It works.
Most helpful comment
I agree with @Catfriend1 here. It's dirty, but Android does dirty things and if we want to play in that ecosystem I think we just need to put on the hazmat suit and get down with it. It would hardly be the first ugly hack to workaround weirdness on Android.
This one has the advantage that you can do it entirely in the App and I don't need to care, too. ;)
It's not like a
echo 'I am a hack' > .stfolder/android.txtwill kill us.(For illustrative purposes only. Please don't implement as a shell script.)