399 //UcxList *resources = read_changes(dir, db); |
399 //UcxList *resources = read_changes(dir, db); |
400 UcxList *resources = cmd_getoption(a, "read") ? |
400 UcxList *resources = cmd_getoption(a, "read") ? |
401 read_changes(dir, db) : local_scan(dir, db); |
401 read_changes(dir, db) : local_scan(dir, db); |
402 |
402 |
403 UCX_FOREACH(elm, resources) { |
403 UCX_FOREACH(elm, resources) { |
404 char *path = elm->data; |
404 LocalResource *local_res = elm->data; |
405 printf("put: %s\n", path); |
405 printf("put: %s\n", local_res->path); |
406 DavResource *res = dav_resource_new(sn, path); |
406 DavResource *res = dav_resource_new(sn, local_res->path); |
407 sync_put_resource(dir, res, db); |
407 if(!sync_put_resource(dir, res, db)) { |
|
408 ucx_map_cstr_put(db->resources, local_res->path, local_res); |
|
409 } |
408 dav_resource_free(res); |
410 dav_resource_free(res); |
409 free(path); |
|
410 } |
411 } |
411 ucx_list_free(resources); |
412 ucx_list_free(resources); |
412 |
413 |
413 // delete all removed files |
414 // delete all removed files |
414 UcxMapIterator i = ucx_map_iterator(db->remove); |
415 UcxMapIterator i = ucx_map_iterator(db->remove); |
465 int isdir; |
466 int isdir; |
466 LocalResource *res = path_to_local_resource(dir, db, new_path, &isdir); |
467 LocalResource *res = path_to_local_resource(dir, db, new_path, &isdir); |
467 if(isdir) { |
468 if(isdir) { |
468 stack = ucx_list_prepend(stack, new_path); |
469 stack = ucx_list_prepend(stack, new_path); |
469 } else if(res) { |
470 } else if(res) { |
470 resources = ucx_list_append(resources, strdup(res->path)); |
471 resources = ucx_list_append(resources, res); |
471 free(new_path); |
472 free(new_path); |
472 } else { |
473 } else { |
473 free(new_path); |
474 free(new_path); |
474 } |
475 } |
475 } |
476 } |
513 |
514 |
514 if(!sstrcmp(name, S("put"))) { |
515 if(!sstrcmp(name, S("put"))) { |
515 int isdir; |
516 int isdir; |
516 LocalResource *res = path_to_local_resource(dir, db, value.ptr, &isdir); |
517 LocalResource *res = path_to_local_resource(dir, db, value.ptr, &isdir); |
517 if(res) { |
518 if(res) { |
518 resources = ucx_list_append(resources, strdup(res->path)); |
519 resources = ucx_list_append(resources, res); |
519 } |
520 } |
520 } else if(!sstrcmp(name, S("remove"))) { |
521 } else if(!sstrcmp(name, S("remove"))) { |
521 int isdir; |
522 int isdir; |
522 //LocalResource *res = path_to_local_resource(dir, db, value.ptr, &isdir); |
523 //LocalResource *res = path_to_local_resource(dir, db, value.ptr, &isdir); |
523 LocalResource *res = calloc(1, sizeof(LocalResource)); |
524 LocalResource *res = calloc(1, sizeof(LocalResource)); |
570 LocalResource *res = calloc(1, sizeof(LocalResource)); |
571 LocalResource *res = calloc(1, sizeof(LocalResource)); |
571 res->path = strdup(path); |
572 res->path = strdup(path); |
572 res->etag = NULL; |
573 res->etag = NULL; |
573 res->last_modified = s.st_mtime; |
574 res->last_modified = s.st_mtime; |
574 res->size = s.st_size; |
575 res->size = s.st_size; |
575 ucx_map_cstr_put(db->resources, res->path, res); |
576 //ucx_map_cstr_put(db->resources, res->path, res); |
576 return res; |
577 return res; |
577 } |
578 } |
578 } else { |
579 } else { |
579 *isdir = 1; |
580 *isdir = 1; |
580 } |
581 } |