71 |
71 |
72 xmlGenericErrorFunc fnc = xmlerrorfnc; |
72 xmlGenericErrorFunc fnc = xmlerrorfnc; |
73 initGenericErrorDefaultFunc(&fnc); |
73 initGenericErrorDefaultFunc(&fnc); |
74 ctx = dav_context_new(); |
74 ctx = dav_context_new(); |
75 load_config(ctx); |
75 load_config(ctx); |
|
76 |
|
77 // copy proxy config |
|
78 memcpy(ctx->http_proxy, get_http_proxy(), sizeof(Proxy)); |
|
79 memcpy(ctx->https_proxy, get_https_proxy(), sizeof(Proxy)); |
|
80 |
76 if(load_sync_config()) { |
81 if(load_sync_config()) { |
77 return EXIT_FAILURE; |
82 return EXIT_FAILURE; |
78 } |
83 } |
79 |
84 |
80 int ret = EXIT_FAILURE; |
85 int ret = EXIT_FAILURE; |
225 // resource is already up-to-date on the client |
230 // resource is already up-to-date on the client |
226 return 0; |
231 return 0; |
227 } |
232 } |
228 } |
233 } |
229 |
234 |
230 if(cdt && s.st_mtim.tv_sec != local->last_modified) { |
235 if(cdt && s.st_mtime != local->last_modified) { |
231 // file modified on the server and on the client |
236 // file modified on the server and on the client |
232 rename_local_file(dir, db, local->path); |
237 rename_local_file(dir, db, local->path); |
233 } |
238 } |
234 } else { |
239 } else { |
235 if(stat(local_path, &s)) { |
240 if(stat(local_path, &s)) { |
434 DIR *local_dir = opendir(local_path); |
439 DIR *local_dir = opendir(local_path); |
435 |
440 |
436 if(!local_dir) { |
441 if(!local_dir) { |
437 fprintf(stderr, "Cannot open directory %s\n", local_path); |
442 fprintf(stderr, "Cannot open directory %s\n", local_path); |
438 } else { |
443 } else { |
|
444 #ifdef _WIN32 |
|
445 long namemax = 255; |
|
446 #else |
439 long namemax = namemax = pathconf(path, _PC_NAME_MAX); |
447 long namemax = namemax = pathconf(path, _PC_NAME_MAX); |
|
448 #endif |
440 if(namemax == 0) { |
449 if(namemax == 0) { |
441 namemax = 255; |
450 namemax = 255; |
442 } |
451 } |
443 struct dirent *ent = malloc(sizeof(struct dirent) + namemax + 1); |
452 struct dirent *ent = malloc(sizeof(struct dirent) + namemax + 1); |
444 struct dirent *res = NULL; |
453 struct dirent *res = NULL; |
538 LocalResource *res = ucx_map_cstr_get(db->resources, path); |
547 LocalResource *res = ucx_map_cstr_get(db->resources, path); |
539 if(res) { |
548 if(res) { |
540 // the file is already in the database |
549 // the file is already in the database |
541 // compare length and lastmodified date |
550 // compare length and lastmodified date |
542 |
551 |
543 if(res->last_modified == s.st_mtim.tv_sec |
552 if(res->last_modified == s.st_mtime |
544 && res->size == s.st_size) |
553 && res->size == s.st_size) |
545 { |
554 { |
546 // file unchanged |
555 // file unchanged |
547 return NULL; |
556 return NULL; |
548 } else { |
557 } else { |
549 // update db entries |
558 // update db entries |
550 res->size = s.st_size; |
559 res->size = s.st_size; |
551 res->last_modified = s.st_mtim.tv_sec; |
560 res->last_modified = s.st_mtime; |
552 |
561 |
553 return res; |
562 return res; |
554 } |
563 } |
555 } else { |
564 } else { |
556 LocalResource *res = calloc(1, sizeof(LocalResource)); |
565 LocalResource *res = calloc(1, sizeof(LocalResource)); |
557 res->path = strdup(path); |
566 res->path = strdup(path); |
558 res->etag = NULL; |
567 res->etag = NULL; |
559 res->last_modified = s.st_mtim.tv_sec; |
568 res->last_modified = s.st_mtime; |
560 res->size = s.st_size; |
569 res->size = s.st_size; |
561 ucx_map_cstr_put(db->resources, res->path, res); |
570 ucx_map_cstr_put(db->resources, res->path, res); |
562 return res; |
571 return res; |
563 } |
572 } |
564 } else { |
573 } else { |