dav/sync.c

changeset 608
3e4c0285a868
parent 607
5dc7fe41e8f8
child 611
a7c48e0dca88
equal deleted inserted replaced
607:5dc7fe41e8f8 608:3e4c0285a868
735 if(dir->hashing) { 735 if(dir->hashing) {
736 // check for moved/copied files 736 // check for moved/copied files
737 UcxList *elm = res_new; 737 UcxList *elm = res_new;
738 UcxList *prev = NULL; 738 UcxList *prev = NULL;
739 UcxList *next = NULL; 739 UcxList *next = NULL;
740 struct stat s; 740 SYS_STAT s;
741 for(;elm;elm=next) { 741 for(;elm;elm=next) {
742 DavResource *res = elm->data; 742 DavResource *res = elm->data;
743 prev = elm->prev; 743 prev = elm->prev;
744 next = elm->next; 744 next = elm->next;
745 745
756 if(!local) { 756 if(!local) {
757 continue; 757 continue;
758 } 758 }
759 759
760 char *local_path = util_concat_path(dir->path, local->path); 760 char *local_path = util_concat_path(dir->path, local->path);
761 int staterr = stat(local_path, &s); 761 int staterr = sys_stat(local_path, &s);
762 free(local_path); 762 free(local_path);
763 if(staterr) { 763 if(staterr) {
764 // origin doesn't exist or is inaccessible 764 // origin doesn't exist or is inaccessible
765 continue; 765 continue;
766 } 766 }
843 char *local_path = create_local_path(dir, res->path); 843 char *local_path = create_local_path(dir, res->path);
844 if(sync_store_metadata(dir, local_path, local, res)) { 844 if(sync_store_metadata(dir, local_path, local, res)) {
845 fprintf(stderr, "Metadata update failed: %s\n", res->path); 845 fprintf(stderr, "Metadata update failed: %s\n", res->path);
846 sync_error++; 846 sync_error++;
847 } else { 847 } else {
848 struct stat s; 848 SYS_STAT s;
849 if(stat(local_path, &s)) { 849 if(sys_stat(local_path, &s)) {
850 fprintf(stderr, "Cannot stat file after update: %s\n", strerror(errno)); 850 fprintf(stderr, "Cannot stat file after update: %s\n", strerror(errno));
851 } 851 }
852 sync_set_metadata_from_stat(local, &s); 852 sync_set_metadata_from_stat(local, &s);
853 sync_success++; 853 sync_success++;
854 } 854 }
1064 1064
1065 free(local_path); 1065 free(local_path);
1066 return ret; 1066 return ret;
1067 } 1067 }
1068 1068
1069 void sync_set_metadata_from_stat(LocalResource *local, struct stat *s) { 1069 void sync_set_metadata_from_stat(LocalResource *local, SYS_STAT *s) {
1070 local->last_modified = s->st_mtime; 1070 local->last_modified = s->st_mtime;
1071 local->mode = s->st_mode & 07777; 1071 local->mode = s->st_mode & 07777;
1072 local->uid = s->st_uid; 1072 local->uid = s->st_uid;
1073 local->gid = s->st_gid; 1073 local->gid = s->st_gid;
1074 local->size = s->st_size; 1074 local->size = s->st_size;

mercurial