--- rsync-2.6.3.orig/receiver.c 2004-09-21 11:24:06.000000000 +0200 +++ rsync-2.6.3/receiver.c 2005-03-02 15:41:26.000000000 +0100 @@ -93,6 +93,7 @@ int i, j; char *argv[1], fbuf[MAXPATHLEN]; static int deletion_count; + int deletion_test_count; if (cvs_exclude) add_cvs_excludes(); @@ -102,6 +103,38 @@ return; } + /* if --max-delete is specified, check that not too many files will be deleted */ + if (max_delete) { + + /* count number of files that would be deleted */ + deletion_test_count=0; + + for (j = 0; j < flist->count; j++) { + if (!(flist->files[j]->flags & FLAG_TOP_DIR) + || !S_ISDIR(flist->files[j]->mode)) + continue; + + argv[0] = f_name_to(flist->files[j], fbuf); + + if (!(local_file_list = send_file_list(-1, 1, argv))) + continue; + + for (i = local_file_list->count-1; i >= 0; i--) { + if (!local_file_list->files[i]->basename) + continue; + if (flist_find(flist,local_file_list->files[i]) < 0) + deletion_test_count++; + } + flist_free(local_file_list); + } + + /* check deletion count */ + if ((deletion_count+deletion_test_count) >= max_delete) { + rprintf(FERROR,"too many files would be deleted - skipping file deletion\n"); + return; + } + } + for (j = 0; j < flist->count; j++) { if (!(flist->files[j]->flags & FLAG_TOP_DIR) || !S_ISDIR(flist->files[j]->mode))