dav/sync.c

changeset 478
baa63fef5c5c
parent 460
22522ff52a62
child 479
6a198e156278
equal deleted inserted replaced
477:9a406db6729b 478:baa63fef5c5c
1808 } 1808 }
1809 1809
1810 return tags; 1810 return tags;
1811 } 1811 }
1812 1812
1813 static int file_seek(FILE *f, curl_off_t offset, int origin) {
1814 int ret = fseek(f, offset, origin);
1815 return ret == 0 ? CURL_SEEKFUNC_OK : CURL_SEEKFUNC_CANTSEEK;
1816 }
1817
1818 size_t myread(void *ptr, size_t size, size_t nmemb, FILE *f) {
1819 size_t ret = fread(ptr, size, nmemb, f);
1820 return ret;
1821 }
1822
1813 int sync_put_resource( 1823 int sync_put_resource(
1814 SyncDirectory *dir, 1824 SyncDirectory *dir,
1815 DavResource *res, 1825 DavResource *res,
1816 LocalResource *local, 1826 LocalResource *local,
1817 int *counter) 1827 int *counter)
1831 fprintf(stderr, "Cannot open file %s\n", local_path); 1841 fprintf(stderr, "Cannot open file %s\n", local_path);
1832 free(local_path); 1842 free(local_path);
1833 return -1; 1843 return -1;
1834 } 1844 }
1835 1845
1836 dav_set_content(res, in, (dav_read_func)fread); 1846 dav_set_content(res, in, (dav_read_func)myread, (dav_seek_func)file_seek);
1837 1847
1838 if(dir->tagconfig) { 1848 if(dir->tagconfig) {
1839 UcxList *tags = sync_get_file_tags(dir, local, NULL); 1849 UcxList *tags = sync_get_file_tags(dir, local, NULL);
1840 DavXmlNode *prop = create_xml_taglist(tags); 1850 DavXmlNode *prop = create_xml_taglist(tags);
1841 if(prop) { 1851 if(prop) {
1866 DavResource *up_res = dav_get(res->session, res->path, "D:getetag,idav:status,idav:tags"); 1876 DavResource *up_res = dav_get(res->session, res->path, "D:getetag,idav:status,idav:tags");
1867 1877
1868 if(up_res) { 1878 if(up_res) {
1869 // the new content length must be equal or greater than the file size 1879 // the new content length must be equal or greater than the file size
1870 if(up_res->contentlength < s.st_size) { 1880 if(up_res->contentlength < s.st_size) {
1871 fprintf(stderr, "Incomplete Upload: %s", local_path); 1881 fprintf(stderr, "Incomplete Upload: %s\n", local_path);
1872 ret = -1; 1882 ret = -1;
1873 // try to set the resource status to 'broken' 1883 // try to set the resource status to 'broken'
1874 sync_set_status(res, "broken"); 1884 sync_set_status(res, "broken");
1875 } else { 1885 } else {
1876 // everything seems fine, we can update the local resource 1886 // everything seems fine, we can update the local resource

mercurial