1747 } |
1747 } |
1748 |
1748 |
1749 return tags; |
1749 return tags; |
1750 } |
1750 } |
1751 |
1751 |
|
1752 static int file_seek(FILE *f, curl_off_t offset, int origin) { |
|
1753 int ret = fseek(f, offset, origin); |
|
1754 return ret == 0 ? CURL_SEEKFUNC_OK : CURL_SEEKFUNC_CANTSEEK; |
|
1755 } |
|
1756 |
|
1757 size_t myread(void *ptr, size_t size, size_t nmemb, FILE *f) { |
|
1758 size_t ret = fread(ptr, size, nmemb, f); |
|
1759 return ret; |
|
1760 } |
|
1761 |
1752 int sync_put_resource( |
1762 int sync_put_resource( |
1753 SyncDirectory *dir, |
1763 SyncDirectory *dir, |
1754 DavResource *res, |
1764 DavResource *res, |
1755 LocalResource *local, |
1765 LocalResource *local, |
1756 int *counter) |
1766 int *counter) |
1770 fprintf(stderr, "Cannot open file %s\n", local_path); |
1780 fprintf(stderr, "Cannot open file %s\n", local_path); |
1771 free(local_path); |
1781 free(local_path); |
1772 return -1; |
1782 return -1; |
1773 } |
1783 } |
1774 |
1784 |
1775 dav_set_content(res, in, (dav_read_func)fread); |
1785 dav_set_content(res, in, (dav_read_func)myread, (dav_seek_func)file_seek); |
1776 |
1786 |
1777 if(dir->tagconfig) { |
1787 if(dir->tagconfig) { |
1778 UcxList *tags = sync_get_file_tags(dir, local, NULL); |
1788 UcxList *tags = sync_get_file_tags(dir, local, NULL); |
1779 DavXmlNode *prop = create_xml_taglist(tags); |
1789 DavXmlNode *prop = create_xml_taglist(tags); |
1780 if(prop) { |
1790 if(prop) { |
1805 DavResource *up_res = dav_get(res->session, res->path, "D:getetag,idav:status,idav:tags"); |
1815 DavResource *up_res = dav_get(res->session, res->path, "D:getetag,idav:status,idav:tags"); |
1806 |
1816 |
1807 if(up_res) { |
1817 if(up_res) { |
1808 // the new content length must be equal or greater than the file size |
1818 // the new content length must be equal or greater than the file size |
1809 if(up_res->contentlength < s.st_size) { |
1819 if(up_res->contentlength < s.st_size) { |
1810 fprintf(stderr, "Incomplete Upload: %s", local_path); |
1820 fprintf(stderr, "Incomplete Upload: %s\n", local_path); |
1811 ret = -1; |
1821 ret = -1; |
1812 // try to set the resource status to 'broken' |
1822 // try to set the resource status to 'broken' |
1813 sync_set_status(res, "broken"); |
1823 sync_set_status(res, "broken"); |
1814 } else { |
1824 } else { |
1815 // everything seems fine, we can update the local resource |
1825 // everything seems fine, we can update the local resource |