New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add error message when filename contains illegal characters for target storage #9395
Comments
@LantashTheTokra Currently, Syncthing doesn't know why the files couldn't be written. It could interrogate the disk partition to determine its format (ext4, NTFS, FAT, etc.), to see what characters are not allowed, but that would require a PR. The shirou/gopsutil package has this functionality. Please note that #7876 would allow these files to be written on FAT formatted partitions, but would require all nodes to be running with this PR. |
Operating systems like Windows and Android (see https://stackoverflow.com/a/64021421) don't allow some characters regardless of the file system, so I don't think simply basing this on the file system alone will work. Syncthing currently uses a hard-coded list of invalid characters and names for Windows, displaying an error message when it encounters them. The same could probably be done for Android on the basis on the character list from the Android source code linked to in the StackOverflow answer. Just for the record, even though the code is named |
This is not reliable, esp on android which actively lies to make applications think certain things are supported. |
We have something in place for Windows AFAIK: syncthing/lib/model/folder_sendrecv.go Line 351 in eb61786
We could do the same for Android. |
One catch with Android is that the restrictions seem to only apply to user storage (both internal and external). For example, if you run Syncthing as root and sync files on the |
I'd rather care about the average user to be honest. Is it even common to have files with such a name there? |
Colons are perfectly reasonable characters to use. |
derp |
Another thought is adding a folder setting to have when Syncthing starts up, to try to create a file for every non-POSIX character ( This would work even when Android lies about the filesystem. |
Yes, except on Android and Windows.
non-ASCII filenames are common though. Having basic error handling behind a feature flag nullifies its purpose. If you're able to find that setting, you're less likely to run into the problem in the first place. |
I found the issue because my laptop runs linux, and I wasted several hours diagnosing the problem because there was no error message about it. |
An unintrusive option would be to have heuristics for detecting potentially invalid filenames after an errors occurs. Compared to trying to detect filename limitations and preventing the error, the worst case is that we have false positives/negatives on error messages. |
I use syncthing with Obsidian, and I frequently want to have a filename that is a question. I tried replacing ? with |
) Currently, Syncthing tries to sync files to Android devices with no consideration for its filename restrictions (see [1]). This commit makes it so that similarly to Windows, Syncthing relies on a hard-coded list of characters which are invalid on Android and displays a specific error message when user tries to sync a file with one of the characters in its name. [1] https://stackoverflow.com/a/64021421 Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com>
) Currently, Syncthing tries to sync files to Android devices with no consideration for its filename restrictions (see [1]). This commit makes it so that similarly to Windows, Syncthing relies on a hard-coded list of characters which are invalid on Android and displays a specific error message when user tries to sync a file with one of the characters in its name. [1] https://stackoverflow.com/a/64021421 Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com>
FWIW, just adding a recent experience with a bar I think it's called in the filename, a "|". Syncing is set up between 5 devices: 1x Linux Ubuntu, 3x Android, 1x Lineage OS (older version). The devices where sync could handle filenames with such "|" character were Ubuntu, old LineageOS (ver. 15 = Android 8) and oldest Android (Nokia 7 Plus running Android 10). |
I'm getting the same error when I try to sync files containing '?' or '"' to android. However on my phone these characters are allowed on the primary external storage I'm syncing to. So as a workaround, I first copied the files there manually (using fsync, preserving modification time), after that Syncthing recognized them and now says the folder is up to date. If I modify one of these files I'll probably have to manually copy it again, but most of my files don't use these characters. On my phone primary external storage is actually internal, and backed by an ext4 filesystem. As far as I know such a setup is quite common for phones with sufficient internal storage. For such phones, Syncthing should just be able to write files containing '?' and other reserved chars. |
Could syncthing on Android simply check the out of sync filenames for problematic characters like :"? and display a more helpful error message then? It only matters when they fail to sync properly. |
Yes, I think. Having a better error message is the point of this issue. |
I had some files making trouble going from Linux to Android 12 (MIUI 13). After some investigation I found that |
On Linux, ? and : are valid characters for filenames. On Android, they are not. As a result, the files cannot be written. My current setup: syncing files between my Linux laptop and Android phone. I tried to sync files that had :'s and ?'s in their names. The sync failed without giving useful error codes.
Current error messages:
In Linux web GUI
(just shows the sync hanging)
Android app
(Error message: "Out of Sync")
Android web GUI
(Error message: "syncing: finishing: opening temp file: open [PATH]/.syncthing.[FILENAME].tmp: operation not permitted"
Proposed warning: "Caution: Filenames contain characters that are not allowed on some operating systems."
The text was updated successfully, but these errors were encountered: