Bug 10051 - Improved long file-name handling
Improved long file-name handling
Status: NEW
Product: rsync
Classification: Unclassified
Component: core
All All
: P5 enhancement
: ---
Assigned To: Wayne Davison
Rsync QA Contact
Depends on:
  Show dependency treegraph
Reported: 2013-07-27 18:14 UTC by Haravikk
Modified: 2013-12-02 00:01 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Haravikk 2013-07-27 18:14:31 UTC
One of the issues with rsync between two different systems is the possibility of file-systems with stricter limitations on the length of a file name or even file path. Now, the latter I'm not sure can be resolved easily, but long names cause two main errors:

rsync: recv_generator: failed to stat "/foo/really_long_name": File name too long (36)
rsync: mkstemp "/foo/" failed: No such file or directory (2)

Basically any attempt to stat an existing file on the receiving end will fail (it probably isn't there anyway). mkstemp then later fails presumably because the temporary name is too long so no file is actually created, it then creates the strange second error which will report the target root as not existing, even though it does.

What I would like to propose is a new feature for handling long file-names, by adding something like the following:

--long-hash (md5|sha1|sha2|none)
--long-hash-ext .rsync.hashed

Quite simply, if a file-name is encountered that is too long for the target file-system, then it is run through the specified hashing algorithm, with the resulting hash being used as the name instead when transferring the file (or looking for an existing file).

The default setting of none would throw an rsync error instead, with the assumption being that renaming the file could introduce errors. For example if you were rsyncing an application bundle but something was renamed then the cloned application may not be functional, so an error would be preferable. However, if you're using rsync for a backup then you may be okay with renaming the file to ensure that it is at least copied.

A possible to addition to this feature would be:

--long-hash-namefile *.rsync.name

Basically this lets you choose a format for a name-file; any file that has to have its named hashed would have a name-file created alongside it using the specified format. If rsync is sending a hashed file with a matching name-file then it can open this in order to restore the original file-name.

For example:

I want to rsync the filename "hugefilename.txt", with the md5 algorithm set rsync will send this as "520b0999cd97ae3af36744e0f9cb1839.rsync.hashed" and create alongside it a file named "520b0999cd97ae3af36744e0f9cb1839.rsync.name" containing the original filename of "huge filename".

Of course naming of the parameters is entirely for example purposes, but hopefully you get the idea. Basically a file with long filename has the name hashed and a suitable extension added, if rsync encounters a file with that extension then it can look for a name-file to expand. When syncing to a folder, if a file has a long file-name then rsync can hash that file-name and look for a .rsync.hashed file to run its usual checks against.