dav/sync.c

changeset 412
dc74f736aea1
parent 411
a182e503617b
child 414
ea50585ec9d9
equal deleted inserted replaced
411:a182e503617b 412:dc74f736aea1
343 int cmd_pull(CmdArgs *a) { 343 int cmd_pull(CmdArgs *a) {
344 if(a->argc != 1) { 344 if(a->argc != 1) {
345 fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many"); 345 fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many");
346 return -1; 346 return -1;
347 } 347 }
348
349 // if there are syntax errors in the command line, fail asap. 348 // if there are syntax errors in the command line, fail asap.
350 SyncTagFilter* tagfilter = parse_tagfilter_string(cmd_getoption(a, "tags")); 349 SyncTagFilter* tagfilter = parse_tagfilter_string(cmd_getoption(a, "tags"));
351 if (!tagfilter) { 350 if (!tagfilter) {
352 fprintf(stderr, "Malformed tag filter\n"); 351 fprintf(stderr, "Malformed tag filter\n");
353 return -1; 352 return -1;
659 } 658 }
660 659
661 int ret = 0; 660 int ret = 0;
662 char *tmp_path = create_tmp_download_path(local_path); 661 char *tmp_path = create_tmp_download_path(local_path);
663 if(res->iscollection) { 662 if(res->iscollection) {
664 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; 663 if(sys_mkdir(local_path) && errno != EEXIST) {
665 if(util_mkdir(local_path, mode) && errno != EEXIST) {
666 ret = -1; 664 ret = -1;
667 } 665 }
668 666
669 if(ret == 0) { 667 if(ret == 0) {
670 if(!local) { 668 if(!local) {
739 local->etag = strdup(etag); 737 local->etag = strdup(etag);
740 local->last_modified = s.st_mtime; 738 local->last_modified = s.st_mtime;
741 local->size = s.st_size; 739 local->size = s.st_size;
742 local->skipped = FALSE; 740 local->skipped = FALSE;
743 } else { 741 } else {
744 if(unlink(tmp_path)) { 742 if(sys_unlink(tmp_path)) {
745 fprintf(stderr, "Cannot remove tmp file: %s\n", tmp_path); 743 fprintf(stderr, "Cannot remove tmp file: %s\n", tmp_path);
746 } 744 }
747 } 745 }
748 } 746 }
749 747
772 770
773 printf("delete: %s\n", res->path); 771 printf("delete: %s\n", res->path);
774 int ret = 0; 772 int ret = 0;
775 if(dir->trash) { 773 if(dir->trash) {
776 move_to_trash(dir, local_path); 774 move_to_trash(dir, local_path);
777 } else if(unlink(local_path)) { 775 } else if(sys_unlink(local_path)) {
778 fprintf(stderr, "Cannot remove file %s\n", local_path); 776 fprintf(stderr, "Cannot remove file %s\n", local_path);
779 ret = -2; 777 ret = -2;
780 } 778 }
781 free(local_path); 779 free(local_path);
782 780
1997 UcxMapIterator i = ucx_map_iterator(db->conflict); 1995 UcxMapIterator i = ucx_map_iterator(db->conflict);
1998 LocalResource *res; 1996 LocalResource *res;
1999 UCX_MAP_FOREACH(key, res, i) { 1997 UCX_MAP_FOREACH(key, res, i) {
2000 printf("delete: %s\n", res->path); 1998 printf("delete: %s\n", res->path);
2001 char *path = util_concat_path(dir->path, res->path); 1999 char *path = util_concat_path(dir->path, res->path);
2002 if(unlink(path)) { 2000 if(sys_unlink(path)) {
2003 if(errno != ENOENT) { 2001 if(errno != ENOENT) {
2004 perror("unlink"); 2002 perror("unlink");
2005 num_err++; 2003 num_err++;
2006 } 2004 }
2007 } else { 2005 } else {
2202 if(S_ISDIR(s.st_mode)) { 2200 if(S_ISDIR(s.st_mode)) {
2203 if(rmdir(path)) { 2201 if(rmdir(path)) {
2204 perror("rmdir"); 2202 perror("rmdir");
2205 } 2203 }
2206 } else { 2204 } else {
2207 if(unlink(path)) { 2205 if(sys_unlink(path)) {
2208 perror("unlink"); 2206 perror("unlink");
2209 } 2207 }
2210 } 2208 }
2211 2209
2212 free(path); 2210 free(path);

mercurial