dav/sync.c

changeset 724
9c2f0072abed
parent 723
5ca174b3247a
child 725
de3b2bb46492
equal deleted inserted replaced
723:5ca174b3247a 724:9c2f0072abed
2156 UCX_FOREACH(elm, removed_res) { 2156 UCX_FOREACH(elm, removed_res) {
2157 LocalResource *local = elm->data; 2157 LocalResource *local = elm->data;
2158 ucx_map_cstr_remove(db->resources, local->path); 2158 ucx_map_cstr_remove(db->resources, local->path);
2159 } 2159 }
2160 2160
2161 ls_new = ucx_list_sort(ls_new, (cmp_func)resource_pathlen_cmp, NULL);
2162 ls_modified = ucx_list_sort(ls_modified, (cmp_func)resource_pathlen_cmp, NULL);
2163 ls_conflict = ucx_list_sort(ls_conflict, (cmp_func)resource_pathlen_cmp, NULL);
2164 ls_update = ucx_list_sort(ls_update, (cmp_func)resource_pathlen_cmp, NULL);
2165 ls_delete = ucx_list_sort(ls_delete, (cmp_func)resource_pathlen_cmp, NULL);
2166 ls_move = ucx_list_sort(ls_move, (cmp_func)resource_pathlen_cmp, NULL);
2167 ls_copy = ucx_list_sort(ls_copy, (cmp_func)resource_pathlen_cmp, NULL);
2168 ls_mkcol = ucx_list_sort(ls_mkcol, (cmp_func)resource_pathlen_cmp, NULL);
2169
2161 if(outgoing) { 2170 if(outgoing) {
2162 print_outgoing( 2171 print_outgoing(
2172 a,
2163 ls_new, 2173 ls_new,
2164 ls_modified, 2174 ls_modified,
2165 ls_conflict, 2175 ls_conflict,
2166 ls_update, 2176 ls_update,
2167 ls_delete, 2177 ls_delete,
2720 free(lastmodified); 2730 free(lastmodified);
2721 free(size); 2731 free(size);
2722 } 2732 }
2723 2733
2724 void print_outgoing( 2734 void print_outgoing(
2735 CmdArgs *args,
2725 UcxList *ls_new, 2736 UcxList *ls_new,
2726 UcxList *ls_modified, 2737 UcxList *ls_modified,
2727 UcxList *ls_conflict, 2738 UcxList *ls_conflict,
2728 UcxList *ls_update, 2739 UcxList *ls_update,
2729 UcxList *ls_delete, 2740 UcxList *ls_delete,
2730 UcxList *ls_move, 2741 UcxList *ls_move,
2731 UcxList *ls_copy, 2742 UcxList *ls_copy,
2732 UcxList *ls_mkcol) 2743 UcxList *ls_mkcol)
2733 { 2744 {
2745 int64_t total_size = 0;
2746
2747 size_t len_new = ucx_list_size(ls_new);
2748 size_t len_mod = ucx_list_size(ls_modified);
2749 size_t len_cnf = ucx_list_size(ls_conflict);
2750 size_t len_upd = ucx_list_size(ls_update);
2751 size_t len_del = ucx_list_size(ls_delete);
2752 size_t len_mov = ucx_list_size(ls_move);
2753 size_t len_cpy = ucx_list_size(ls_copy);
2754 size_t len_mkc = ucx_list_size(ls_mkcol);
2755
2756 size_t total = len_new + len_mod + len_cnf + len_upd + len_del + len_mov + len_cpy + len_mkc;
2757 if(total == 0) {
2758 printf("no changes\n");
2759 return;
2760 }
2761
2734 printf("%s\n", "File Last Modified Size"); 2762 printf("%s\n", "File Last Modified Size");
2735 printf("%s\n", "=============================================================================="); 2763 printf("%s\n", "==============================================================================");
2736 2764
2737 int num_files = 0;
2738 int64_t total_size = 0;
2739
2740 if(ls_mkcol) { 2765 if(ls_mkcol) {
2741 printf("Directories:\n"); 2766 printf("Directories:\n");
2742 UCX_FOREACH(elm, ls_mkcol) { 2767 UCX_FOREACH(elm, ls_mkcol) {
2743 LocalResource *res = elm->data; 2768 LocalResource *res = elm->data;
2744 printf(" %-49s\n", res->path+1); 2769 printf(" %-49s\n", res->path+1);
2745 total_size += res->size; 2770 total_size += res->size;
2746 num_files++;
2747 } 2771 }
2748 } 2772 }
2749 if(ls_new) { 2773 if(ls_new) {
2750 printf("New:\n"); 2774 printf("New:\n");
2751 UCX_FOREACH(elm, ls_new) { 2775 UCX_FOREACH(elm, ls_new) {
2752 LocalResource *res = elm->data; 2776 LocalResource *res = elm->data;
2753 print_outgoging_file(elm->data); 2777 print_outgoging_file(elm->data);
2754 total_size += res->size; 2778 total_size += res->size;
2755 num_files++;
2756 } 2779 }
2757 } 2780 }
2758 if(ls_modified) { 2781 if(ls_modified) {
2759 printf("Modified:\n"); 2782 printf("Modified:\n");
2760 UCX_FOREACH(elm, ls_modified) { 2783 UCX_FOREACH(elm, ls_modified) {
2761 LocalResource *res = elm->data; 2784 LocalResource *res = elm->data;
2762 print_outgoging_file(elm->data); 2785 print_outgoging_file(elm->data);
2763 total_size += res->size; 2786 total_size += res->size;
2764 num_files++;
2765 } 2787 }
2766 } 2788 }
2767 if(ls_update) { 2789 if(ls_update) {
2768 printf("Update:\n"); 2790 printf("Update:\n");
2769 UCX_FOREACH(elm, ls_update) { 2791 UCX_FOREACH(elm, ls_update) {
2770 LocalResource *res = elm->data; 2792 LocalResource *res = elm->data;
2771 char *lastmodified = util_date_str(res->last_modified); 2793 char *lastmodified = util_date_str(res->last_modified);
2772 printf(" %-49s %12s\n", res->path+1, lastmodified); 2794 printf(" %-49s %12s\n", res->path+1, lastmodified);
2773 free(lastmodified); 2795 free(lastmodified);
2774 num_files++;
2775 } 2796 }
2776 } 2797 }
2777 if(ls_delete) { 2798 if(ls_delete) {
2778 printf("Delete:\n"); 2799 printf("Delete:\n");
2779 UCX_FOREACH(elm, ls_delete) { 2800 UCX_FOREACH(elm, ls_delete) {
2784 if(ls_copy) { 2805 if(ls_copy) {
2785 printf("Copy:\n"); 2806 printf("Copy:\n");
2786 UCX_FOREACH(elm, ls_copy) { 2807 UCX_FOREACH(elm, ls_copy) {
2787 LocalResource *res = elm->data; 2808 LocalResource *res = elm->data;
2788 printf("%s -> %s\n", res->origin->path+1, res->path); 2809 printf("%s -> %s\n", res->origin->path+1, res->path);
2789 num_files++;
2790 } 2810 }
2791 } 2811 }
2792 if(ls_move) { 2812 if(ls_move) {
2793 printf("Move:\n"); 2813 printf("Move:\n");
2794 UCX_FOREACH(elm, ls_move) { 2814 UCX_FOREACH(elm, ls_move) {
2795 LocalResource *res = elm->data; 2815 LocalResource *res = elm->data;
2796 printf("%s -> %s\n", res->origin->path+1, res->path); 2816 printf("%s -> %s\n", res->origin->path+1, res->path);
2797 num_files++;
2798 } 2817 }
2799 } 2818 }
2800 if(ls_conflict) { 2819 if(ls_conflict) {
2801 printf("Conflict\n"); 2820 printf("Conflict\n");
2802 UCX_FOREACH(elm, ls_conflict) { 2821 UCX_FOREACH(elm, ls_conflict) {
2804 printf(" %s\n", res->path+1); 2823 printf(" %s\n", res->path+1);
2805 } 2824 }
2806 } 2825 }
2807 2826
2808 char *total_size_str = util_size_str(FALSE, total_size); 2827 char *total_size_str = util_size_str(FALSE, total_size);
2809 printf("\n%d outgoing files, size: %s\n", num_files, total_size_str); 2828
2829 printf("\n");
2830 if(len_new > 0) printf("new: %zu, ", len_new);
2831 if(len_mod > 0) printf("modified: %zu, ", len_mod);
2832 if(len_upd > 0) printf("updated: %zu, ", len_upd);
2833 if(len_cpy > 0) printf("copied: %zu, ", len_cpy);
2834 if(len_mov > 0) printf("moved: %zu, ", len_mov);
2835 if(len_del > 0) printf("deleted: %zu, ", len_del);
2836 if(len_cnf > 0) printf("conflicts: %zu, ", len_cnf);
2837 printf("total size: %s\n", total_size_str);
2838
2810 free(total_size_str); 2839 free(total_size_str);
2811 } 2840 }
2812 2841
2813 UcxList* local_scan(SyncDirectory *dir, SyncDatabase *db) { 2842 UcxList* local_scan(SyncDirectory *dir, SyncDatabase *db) {
2814 UcxList *resources = NULL; 2843 UcxList *resources = NULL;

mercurial