You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rename special/unsupported characters in filenames #1734
This needs to happen on the source then, or we need to keep the translation in the database somewhere, and hilariousness ensues when the database is reset or lost.
I would think that with the substitution of characters it wouldn't really be required on each machine's database... would it not be possible to just check files incoming/outgoing against the substituted version, if they exist already on the host or don't, do what's appropriate?
I would think that with the substitution of characters it wouldn't really be required on each machine's database... would it not be possible to just check files incoming/outgoing against the substituted version, if they exist already on the host or don't, do what's appropriate?
No. Consider a case where a *nix machine has two files in a directory, and their contents are unique:
Simply renaming each file by substituting offending characters would not work. You would end up with two conflicting files, each named foo_bar.
Also, consider this scenario:
A user has a *nix machine with a file on it named foo:bar.
The user adds a Windows machine to the syncthing cluster. The file is copied to the Windows machine as foo_bar.
The user adds a second *nix machine to the syncthing cluster. This second *nix machine receives a file named foo:bar from the first *nix machine and a file named foo_bar from the Windows machine.
Moreover there are other forbidden names under Windows: for example, nul or com1 and several other, or names longer than 255 characters. And names cannot end with a dot or space. And Mac could be a problem too: I think it requires normalized unicode, while in Linux normalized and non-normalized version could be two different files. (I'm just remembering, cannot verify right now, maybe there are some imprecisions).
We enforce unicode normalization; there's been some pain around that, for people having files with the "wrong" normalization for their OS. There we actually silently fix it, unless configured otherwise.
for example, nul or com1 and several other, or names longer than 255 characters. And names cannot end with a dot or space.
😱 I'd forgotten about the first of that, and didn't know about the second. We should probably handle that too (at least with a reject). Dammit, Windows...
But @Ichimonji10 above summarizes quite nicely why we probably won't be doing character substitutions anytime soon.
Just to add all the information in one place: you have to handle case sensitivity too.
Moreover, the problem is not with Windows bit also affects NTFS with other OSs. While in Linux shares under Windows have an error if trying to create a wrong filename, direct NTFS mounts do not have errors by default, and files are accessibile under Linux but not under Windows. So, you cannot rely on errors to know if a filename is legal.
This is maybe even crazier idea, but how about simple escaping? On windows, invalid character in incoming file names can be substituted, All*files? to All^afiles^q, for example, and reversed substitution can be used for outgoing files. Substitution may be configurable per-repository and enabled on Windows by default, so this would help even with samba mounts on *nixes.
We could do escaping, but it would have to be to something the user would not enter herself (to avoid confusion), and it would be ugly. I.e. foo:bar -> st--foo%3abar. The point being that we should be able to recognize the escaping even if the database is gone and we're doing an initial scan. I have files with legitimate ^'s in them (well, legitimateness can be debated, but they are there) and probably the same goes for someone else and whatever other character we could think of.
The case sensitivityness is an open bug somewhere else.
And I don't think should try to guess hidden rules when the OS and filesystem are fine with them...
I have files with legitimate ^'s in them (well, legitimateness can be debated, but they are there) and probably the same goes for someone else and whatever other character we could think of.
True, but that can be "solved" by escaping escape character, so incoming file^2 would become file^^2. Of course, if user manages to create file^a manually on Windows machine, Linux will receive file*. I can't argue it's not ugly, but it's not ambiguous.
There is also thing that cygwin does - they are translating invalid characters to character from unicode private space. That may, in plain theory, create conflicts, but chances are really slim and it looks better.
To be honest, I think the much simpler solution is for people who sync across multiple OS:es to just stick to the lowest common denominator in file names or live with the errors. It's not that onerous, and people using more than one platform should be kind of aware of the issue. For cases where someone has just a Windows box and a NAS running Linux, they'll most likely create all their files from the Windows side and automatically stay within the limitations.
(The case sensitivity thing still needs to be handled better though.)
You're right, but there is at least one case in which I'd like a solution.
I use it to backup my Android photos. If I take a photo with Hangouts app,
the file gets saved with a `:nopm:` suffix.
I think the much simpler solution is for people who sync across multiple OS:es to just stick to the lowest common denominator in file names or live with the errors.
There are two problems with this approach.
Sometimes user can't choose what characters are included.
User usually realizes that [:-)] is invalid Windows filename only after he can't find it on other side. And that may be especially sweet realization if source machine is already offline.
I don't see point number one related to syncthing; that'd be a problem for the poor user on Windows with someone forcing invalid filenames on him no matter the delivery mechanism? Point number two implies the user is also a Linux user, who I'm assuming are more aware about things like filesystems and name limitations?
(This is all to say that I think this should be solved in a clean way, not that we shouldn't solve it at all. But something that is really ugly or has bad side effects is probably not worth it IMHO.)
Activity
calmh commentedon Apr 29, 2015
This needs to happen on the source then, or we need to keep the translation in the database somewhere, and hilariousness ensues when the database is reset or lost.
neclepsio commentedon May 4, 2015
Maybe there could be a warning on the source, inviting to rename the file to avoid problems.
somasis commentedon May 4, 2015
I would think that with the substitution of characters it wouldn't really be required on each machine's database... would it not be possible to just check files incoming/outgoing against the substituted version, if they exist already on the host or don't, do what's appropriate?
jeremy-audet commentedon May 4, 2015
No. Consider a case where a *nix machine has two files in a directory, and their contents are unique:
Simply renaming each file by substituting offending characters would not work. You would end up with two conflicting files, each named
foo_bar.Also, consider this scenario:
foo:bar.foo_bar.foo:barfrom the first *nix machine and a file namedfoo_barfrom the Windows machine.Oops. One file magically became two files.
neclepsio commentedon May 4, 2015
Moreover there are other forbidden names under Windows: for example, nul or com1 and several other, or names longer than 255 characters. And names cannot end with a dot or space. And Mac could be a problem too: I think it requires normalized unicode, while in Linux normalized and non-normalized version could be two different files. (I'm just remembering, cannot verify right now, maybe there are some imprecisions).
calmh commentedon May 4, 2015
We enforce unicode normalization; there's been some pain around that, for people having files with the "wrong" normalization for their OS. There we actually silently fix it, unless configured otherwise.
😱 I'd forgotten about the first of that, and didn't know about the second. We should probably handle that too (at least with a reject). Dammit, Windows...
But @Ichimonji10 above summarizes quite nicely why we probably won't be doing character substitutions anytime soon.
neclepsio commentedon May 5, 2015
Just to add all the information in one place: you have to handle case sensitivity too.
Moreover, the problem is not with Windows bit also affects NTFS with other OSs. While in Linux shares under Windows have an error if trying to create a wrong filename, direct NTFS mounts do not have errors by default, and files are accessibile under Linux but not under Windows. So, you cannot rely on errors to know if a filename is legal.
kozec commentedon May 5, 2015
This is maybe even crazier idea, but how about simple escaping? On windows, invalid character in incoming file names can be substituted,
All*files?toAll^afiles^q, for example, and reversed substitution can be used for outgoing files. Substitution may be configurable per-repository and enabled on Windows by default, so this would help even with samba mounts on *nixes.calmh commentedon May 5, 2015
We could do escaping, but it would have to be to something the user would not enter herself (to avoid confusion), and it would be ugly. I.e.
foo:bar->st--foo%3abar. The point being that we should be able to recognize the escaping even if the database is gone and we're doing an initial scan. I have files with legitimate^'s in them (well, legitimateness can be debated, but they are there) and probably the same goes for someone else and whatever other character we could think of.The case sensitivityness is an open bug somewhere else.
And I don't think should try to guess hidden rules when the OS and filesystem are fine with them...
kozec commentedon May 5, 2015
True, but that can be "solved" by escaping escape character, so incoming
file^2would becomefile^^2. Of course, if user manages to createfile^amanually on Windows machine, Linux will receivefile*. I can't argue it's not ugly, but it's not ambiguous.There is also thing that cygwin does - they are translating invalid characters to character from unicode private space. That may, in plain theory, create conflicts, but chances are really slim and it looks better.
calmh commentedon May 5, 2015
To be honest, I think the much simpler solution is for people who sync across multiple OS:es to just stick to the lowest common denominator in file names or live with the errors. It's not that onerous, and people using more than one platform should be kind of aware of the issue. For cases where someone has just a Windows box and a NAS running Linux, they'll most likely create all their files from the Windows side and automatically stay within the limitations.
(The case sensitivity thing still needs to be handled better though.)
neclepsio commentedon May 5, 2015
kozec commentedon May 5, 2015
There are two problems with this approach.
[:-)]is invalid Windows filename only after he can't find it on other side. And that may be especially sweet realization if source machine is already offline.calmh commentedon May 5, 2015
I don't see point number one related to syncthing; that'd be a problem for the poor user on Windows with someone forcing invalid filenames on him no matter the delivery mechanism? Point number two implies the user is also a Linux user, who I'm assuming are more aware about things like filesystems and name limitations?
calmh commentedon May 5, 2015
(This is all to say that I think this should be solved in a clean way, not that we shouldn't solve it at all. But something that is really ugly or has bad side effects is probably not worth it IMHO.)
63 remaining items
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters
lib/fs: Add syncing of reserved FAT characters