1603 UcxMapIterator i = ucx_map_iterator(files ? files : db->resources); |
1603 UcxMapIterator i = ucx_map_iterator(files ? files : db->resources); |
1604 LocalResource *resource; |
1604 LocalResource *resource; |
1605 UCX_MAP_FOREACH(key, resource, i) { |
1605 UCX_MAP_FOREACH(key, resource, i) { |
1606 if(resource == &nres) { |
1606 if(resource == &nres) { |
1607 resource = ucx_map_get(db->resources, key); |
1607 resource = ucx_map_get(db->resources, key); |
|
1608 if(!resource) { |
|
1609 continue; |
|
1610 } |
1608 } |
1611 } |
1609 |
1612 |
1610 char *file_path = util_concat_path(dir->path, resource->path); |
1613 char *file_path = util_concat_path(dir->path, resource->path); |
1611 SYS_STAT s; |
1614 SYS_STAT s; |
1612 if(sys_stat(file_path, &s)) { |
1615 if(sys_stat(file_path, &s)) { |
1616 } |
1619 } |
1617 } else { |
1620 } else { |
1618 fprintf(stderr, "Cannot stat file: %s\n", file_path); |
1621 fprintf(stderr, "Cannot stat file: %s\n", file_path); |
1619 perror(""); |
1622 perror(""); |
1620 } |
1623 } |
1621 } else if(!resource->isdirectory && !S_ISDIR(s.st_mode)) { |
1624 } else { |
1622 if(resource->last_modified != s.st_mtime || resource->size != s.st_size) { |
1625 if(files) { |
1623 if(restore_modified) { |
1626 modified = ucx_list_prepend(modified, resource); |
1624 modified = ucx_list_prepend(modified, resource); |
1627 } else if(!resource->isdirectory && !S_ISDIR(s.st_mode)) { |
|
1628 if(resource->last_modified != s.st_mtime || resource->size != s.st_size) { |
|
1629 if(restore_modified) { |
|
1630 modified = ucx_list_prepend(modified, resource); |
|
1631 } |
1625 } |
1632 } |
1626 } |
1633 } |
1627 } |
1634 } |
1628 |
1635 |
1629 free(file_path); |
1636 free(file_path); |
1676 |
1683 |
1677 UCX_FOREACH(elm, resources) { |
1684 UCX_FOREACH(elm, resources) { |
1678 LocalResource *resource = elm->data; |
1685 LocalResource *resource = elm->data; |
1679 |
1686 |
1680 DavResource *res = dav_get(sn, resource->path, "D:getetag,idav:status,idav:finfo,idav:xattributes"); |
1687 DavResource *res = dav_get(sn, resource->path, "D:getetag,idav:status,idav:finfo,idav:xattributes"); |
1681 |
1688 if(!res) { |
|
1689 printf("skip: %s\n", resource->path); |
|
1690 continue; |
|
1691 //continue; |
|
1692 } |
1682 char *status = dav_get_string_property(res, "idav:status"); |
1693 char *status = dav_get_string_property(res, "idav:status"); |
1683 if(status && !strcmp(status, "broken")) { |
1694 if(status && !strcmp(status, "broken")) { |
1684 continue; |
1695 continue; |
1685 } |
1696 } |
1686 |
1697 |
1687 // download the resource |
1698 // download the resource |
1688 if(!sync_shutdown && sync_get_resource(a, dir, res, db, &sync_success)) { |
1699 if(!sync_shutdown) { |
1689 fprintf(stderr, "sync_get_resource failed for resource: %s\n", res->path); |
1700 if(resource->isdirectory) { |
1690 sync_error++; |
1701 char *local_path = util_concat_path(dir->path, res->path); |
|
1702 if(sys_mkdir(local_path) && errno != EEXIST) { |
|
1703 fprintf(stderr, |
|
1704 "Cannot create directory %s: %s", |
|
1705 local_path, strerror(errno)); |
|
1706 } |
|
1707 free(local_path); |
|
1708 } else { |
|
1709 if(sync_get_resource(a, dir, res, db, &sync_success)) { |
|
1710 fprintf(stderr, "sync_get_resource failed for resource: %s\n", res->path); |
|
1711 sync_error++; |
|
1712 } |
|
1713 } |
1691 } |
1714 } |
1692 } |
1715 } |
1693 |
1716 |
1694 // unlock repository |
1717 // unlock repository |
1695 if(locked) { |
1718 if(locked) { |