Folder marker missing, but .stfolder exists

My ST on Android stopped synchronizing my DCIM/Camera folder because of the following error:

Error on folder “Camera” (abcde-fghij): folder marker missing (this indicates potential data loss, search docs/forum to get information about how to proceed)

I’ve checked that .stfolder directory exists and that in advanced settings of the Camera folder there is Marker Name set to .stfolder too. I’ve tried to restart ST or the folder, to recreate the .stfolder, but nothing helped.

What can cause the problem?

Hi,

Which of the various Androids are you on?

Syncthing 1.7.1 on LG G6 with Android 9.

I don’t think that this is related with ST version 1.7, last successful synchronization was about in May. I’ve got several folders set up on this mobile phone, but only the “Camera” folder reports this problem.

The synchronization on “Camera” is set up as unidirectional (phone -> NAS). .stfolder exists both on the phone and on NAS. NAS does not report any error.

Ok, I’d also expect this to work. Wondering why recreate didn’t help if data was still intact and in place?!

Is missing .stfolder the only possible reason for this error to occur? Cannot it be caused by something else?

If storage permissions would have gone missing, the app should refuse to start at all and go to the welcome screen.

The Camera folder is on the SD-card. But the other (working) folders are on the SD-card too… It doesn’t look like missing permissions to me.

Permissions are per file/folder. So it’s entirely possible this is still the cause. Just because another folder has the correct permissions, doesn’t mean the folder in question does. The permissions for an SD card are not identical across dirs, it’s like any other file system. Check permissions with a file app on the known good folders and make sure the problematic folder matches.

I managed to resolve the problem…somehow. The problem was indeed in privileges, but I still do not understand what was the problem.

I backed-up the Syncthing config, reinstalled the application, granted access to the SD-card, and restored the config - but the problem was still the same.

Then, I removed the .stfolder and let Syncthing to create it itself - and this helped.

So, it seems that when I create .stfolder manually, Syncthing does not have privileges to this folder. This I do not understand because Syncthing was granted privileges to the whole SD-card.

Hi,

this is a good observation granting some insight into how the Android OS on your phone works. I can make a guess this has to do with the scoped storage implementation which I expect does some recording of which app/process does tinker with which files on your SDcard. To create the marker yourself, Android sees the world like another app does “own” the file. “own” is not meant in the context of a unix file owner in this case.

I didn’t know it’s even possible. I knew that you can grant access only to a folder on an SD-card, not to the whole SD-card (if the app allows it), but I thought that’s all you can do.

If it is the case as you’re writing, what’s the purpose of granting access to Syncthing for the whole SD-card, if it still can’t access everything?

This is the expected behaviour.

Android asks if the app can access the card when you first start the app, but this is just Android checking if you want the app to even have visibility of it and permission to use it.

The file system of the card itself is entirely different. If you manually create a folder instead of letting syncthing do it, the permissions may be wrong. This is why deleting the app and reinstalling did not help. Once you deleted the folder and allowed syncthing to recreate it, it was created correctly with the correct permissions.

If granting an app permission to see a card from an Android OS perspective changed all the file system permissions on it at the same time, it would be disastrous for other apps that have specific permissions.

I still don’t understand this, I’ll have to read something about how Android handles permissions on SD-cards. The thing is that this has changed many times in the last few years, and as @Catfriend1 suggests, each vendor may implement it differently. I am no expert for Android, I treat it like Linux :-).

Think of it like this:

A house has a front door you either have a key or you don’t. The house is the SD card, the key is when you say you want the app to access the card.

Inside the house, there are multiple belongings that could belong to multiple users/apps (files and folders). Each of these you may or may not touch (permissions).

There is also a security guard in the house to make sure you don’t touch anything you should not (the OS kernel). If you don’t have permissions to touch it, you can’t.

If the person who owns the belonging gives you permission, you can touch something. But just because you are allowed in the house doesn’t mean all the stuff belongs to you.

And, if you create a file/folder without giving access to someone else, they cannot touch it. So when you created the folder you didn’t give the syncthing app permission. When it creates it, it creates it as it’s own.

I understood what you wrote even in your previous post. But it contradicts what I thought I knew about this. What you’re describing feels to me rather as a description of the internal storage than of an SD-card. And even when I accept what you write (I do not doubt you know what you’re writing) such a behaviour seems inconsistent to me and there are many aspects of it I do not understand. I’ll have to read something about it.

Ok, but last comment on it: The OS doesn’t care whether it’s internal storage (flash) or an SD card. For most situations, storage is storage. It will all behave the same. Each has access permissions (the entire thing) and individual file folder permissions on a file system level.

I do not know how it is now, but a few years ago (Android 6/7?) there was a huge distinction between how OS treated privileges in the internal storage and in the SD-card. But as I said, this probably has changed again since then.

There may have been some differences with certain locations and their “standard” permissions (like in the root dir) on previous versions, but I am unaware of any massive differences that would affect this… maybe with 4 or 2. But I could be totally wrong though as I am not familiar with every android version. If you find anything post back here as it’d be good to know :slight_smile: