Bug 3824 - Max-delete with percentage
Summary: Max-delete with percentage
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 2.6.8
Hardware: All Windows XP
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
Depends on:
Reported: 2006-06-05 15:25 UTC by James Bromberger
Modified: 2006-10-15 13:11 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description James Bromberger 2006-06-05 15:25:08 UTC
Max-delete currently takes a number of files as a bound on deletions. Would be nice that if a % character is on this number, then we have max delete as a percentage of files on the deleting side to be removed (eg, rsync -a source::dir/ dest/ --max-delete=10%).
Comment 1 Matt McCutchen 2006-06-06 17:28:56 UTC
A percentage --max-delete would be difficult to implement.  The generator would need to know the total number of files in the target directory in order to decide whether to delete or skip deleting the first extraneous file.  The files could be counted in a separate pass during startup and deleted during the main pass, or they could be counted during the main pass for deletion in a separate pass at the end of the transfer.

Do you have a specific case in which a percentage --max-delete would be useful?   If not, the above sounds like a lot of mess for a minor improvement.

Instead, a numeric max-delete could be calculated from a percentage outside of rsync using a find command:
  rsync <options> src/ dest/ \
    --max-delete=$(($(find dest/ -printf x | wc -c)*$percent/100))
It would take more work to omit files protected from deletion by filters from the total.
Comment 2 Wayne Davison 2006-10-15 13:11:08 UTC
I'd rather not add this.  Thanks for the idea, though.