Bug 10785 - [PATCH] Add a flag to use numeric sort
Summary: [PATCH] Add a flag to use numeric sort
Status: RESOLVED INVALID
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.1.1
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-26 17:01 UTC by rom
Modified: 2014-09-12 07:44 UTC (History)
0 users

See Also:


Attachments
the patch (3.21 KB, patch)
2014-08-26 17:01 UTC, rom
no flags Details
the patch (v2) (3.26 KB, patch)
2014-08-26 21:43 UTC, rom
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description rom 2014-08-26 17:01:52 UTC
Created attachment 10229 [details]
the patch

I need to sync a lot of files with non-zero-padded numbered filenames.

I would like them to be transferred in order, to be able to use "partial" transfers (it takes a lot of time to transfer the whole data).

My concrete need is to rsync duplicity backups. Let's say I have 21 files. For now, they are transferred in that order :

duplicity-full.20140531T230029Z.vol1.difftar.gpg
duplicity-full.20140531T230029Z.vol10.difftar.gpg
duplicity-full.20140531T230029Z.vol11.difftar.gpg
duplicity-full.20140531T230029Z.vol12.difftar.gpg
duplicity-full.20140531T230029Z.vol13.difftar.gpg
duplicity-full.20140531T230029Z.vol14.difftar.gpg
duplicity-full.20140531T230029Z.vol15.difftar.gpg
duplicity-full.20140531T230029Z.vol16.difftar.gpg
duplicity-full.20140531T230029Z.vol17.difftar.gpg
duplicity-full.20140531T230029Z.vol18.difftar.gpg
duplicity-full.20140531T230029Z.vol19.difftar.gpg
duplicity-full.20140531T230029Z.vol2.difftar.gpg
duplicity-full.20140531T230029Z.vol20.difftar.gpg
duplicity-full.20140531T230029Z.vol21.difftar.gpg
duplicity-full.20140531T230029Z.vol3.difftar.gpg
duplicity-full.20140531T230029Z.vol4.difftar.gpg
duplicity-full.20140531T230029Z.vol5.difftar.gpg
duplicity-full.20140531T230029Z.vol6.difftar.gpg
duplicity-full.20140531T230029Z.vol7.difftar.gpg
duplicity-full.20140531T230029Z.vol8.difftar.gpg
duplicity-full.20140531T230029Z.vol9.difftar.gpg

This is not good, because if the transfer is partial, they are not exploitable (I have to sync all files 10 to 19 – and 100 to 199, 1000 to 1999 – before transferring file 2).

Thus, I added a --numeric-sort (-N) option to rsync, to transfer the files in the expected order.

Patch attached. Feedbacks welcome.
Comment 1 rom 2014-08-26 21:43:38 UTC
Created attachment 10230 [details]
the patch (v2)

An explicit 'int' return type was missing for must_numsort() the patch v1 added. The patch v2 only adds this 'int' (compared to patch v1).
Comment 2 rom 2014-09-12 07:43:31 UTC
Arf, it breaks file selection and file content under some conditions (remote transfer and partial sync — when some files are already present).

So (at least for now), I close this bug/patch.