dav/sync.c

branch
v1.2
changeset 481
ff477f1f7765
parent 464
37da70159bf6
child 482
d96464f42b84
--- a/dav/sync.c	Sun Oct 07 09:14:03 2018 +0200
+++ b/dav/sync.c	Thu Oct 11 19:29:45 2018 +0200
@@ -1749,6 +1749,16 @@
     return tags;
 }
 
+static int file_seek(FILE *f, curl_off_t offset, int origin) {
+    int ret = fseek(f, offset, origin);
+    return ret == 0 ? CURL_SEEKFUNC_OK : CURL_SEEKFUNC_CANTSEEK;
+}
+
+size_t myread(void *ptr, size_t size, size_t nmemb, FILE *f) {
+    size_t ret = fread(ptr, size, nmemb, f);
+    return ret;
+}
+
 int sync_put_resource(
         SyncDirectory *dir,
         DavResource *res,
@@ -1772,7 +1782,7 @@
         return -1;
     }
     
-    dav_set_content(res, in, (dav_read_func)fread);
+    dav_set_content(res, in, (dav_read_func)myread, (dav_seek_func)file_seek);
     
     if(dir->tagconfig) {
         UcxList *tags = sync_get_file_tags(dir, local, NULL);
@@ -1807,7 +1817,7 @@
         if(up_res) {
             // the new content length must be equal or greater than the file size
             if(up_res->contentlength < s.st_size) {
-                fprintf(stderr, "Incomplete Upload: %s", local_path);
+                fprintf(stderr, "Incomplete Upload: %s\n", local_path);
                 ret = -1;
                 // try to set the resource status to 'broken'
                 sync_set_status(res, "broken");

mercurial