dav/sync.c

changeset 617
1c995e93bf40
parent 616
0b61755f2852
child 618
4b34d12cf211
equal deleted inserted replaced
616:0b61755f2852 617:1c995e93bf40
978 if(!exists) { 978 if(!exists) {
979 ret = REMOTE_CHANGE_MKDIR; 979 ret = REMOTE_CHANGE_MKDIR;
980 } else if(local && S_ISDIR(s.st_mode)) { 980 } else if(local && S_ISDIR(s.st_mode)) {
981 local->isdirectory = 1; // make sure isdirectory is set 981 local->isdirectory = 1; // make sure isdirectory is set
982 } else { 982 } else {
983 // TODO: conflict 983 // set change to REMOTE_CHANGE_MKDIR, which will fail later
984 ret = REMOTE_NO_CHANGE; 984 ret = REMOTE_CHANGE_MKDIR;
985 } 985 }
986 } else if(local) { 986 } else if(local) {
987 DavBool nochange = FALSE; 987 DavBool nochange = FALSE;
988 char *content_hash = sync_get_content_hash(res); 988 char *content_hash = sync_get_content_hash(res);
989 989
1479 SyncDatabase *db) 1479 SyncDatabase *db)
1480 { 1480 {
1481 char *res_path = resource_local_path(res); 1481 char *res_path = resource_local_path(res);
1482 char *local_path = create_local_path(dir, res->path); 1482 char *local_path = create_local_path(dir, res->path);
1483 free(res_path); 1483 free(res_path);
1484 1484
1485 printf("get: %s\n", res->path); 1485 printf("get: %s\n", res->path);
1486 // create directory 1486 // create directory
1487 // ignore error if it already exists 1487 // ignore error if it already exists
1488 if(sys_mkdir(local_path) && errno != EEXIST) { 1488 if(sys_mkdir(local_path) && errno != EEXIST) {
1489 fprintf(stderr, 1489 fprintf(stderr,
1490 "Cannot create directory %s: %s", 1490 "Cannot create directory %s: %s",
1491 local_path, strerror(errno)); 1491 local_path, strerror(errno));
1492 free(local_path); 1492 free(local_path);
1493 return 1; 1493 return 1;
1494 } 1494 }
1495
1496 // stat for getting metadata
1495 SYS_STAT s; 1497 SYS_STAT s;
1496 if(sys_stat(local_path, &s)) { 1498 if(sys_stat(local_path, &s)) {
1497 fprintf(stderr, "Cannot stat directory %s: %s", local_path, strerror(errno)); 1499 fprintf(stderr, "Cannot stat directory %s: %s", local_path, strerror(errno));
1498 free(local_path); 1500 free(local_path);
1499 return 1; 1501 return 1;
1500 } 1502 }
1501 1503
1502 // if it doesn't exist in the db, create an entry for the dir 1504 // if it doesn't exist in the db, create an entry for the dir
1503 LocalResource *local = ucx_map_cstr_get(db->resources, res->path); 1505 LocalResource *local = ucx_map_cstr_get(db->resources, res->path);
1504 if(!local) { 1506 if(!local) {
1505 local = calloc(1, sizeof(LocalResource)); 1507 local = calloc(1, sizeof(LocalResource));
1506 local->path = strdup(res->path); 1508 local->path = strdup(res->path);

mercurial