[Pkg-owncloud-commits] [owncloud-client] 22/332: CSync: Remove owncloud_stat

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:33 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 0dcc9be5c1cd2012abf1070531d72dbe7b13bcc2
Author: Markus Goetz <markus at woboq.com>
Date:   Wed May 28 12:07:27 2014 +0200

    CSync: Remove owncloud_stat
    
    We get already all metadata with the readdir
---
 csync/src/csync_owncloud.c | 99 ----------------------------------------------
 csync/src/csync_owncloud.h |  1 -
 csync/src/csync_update.c   | 18 ++++++---
 csync/src/vio/csync_vio.c  |  2 +-
 4 files changed, 13 insertions(+), 107 deletions(-)

diff --git a/csync/src/csync_owncloud.c b/csync/src/csync_owncloud.c
index cba1737..23be021 100644
--- a/csync/src/csync_owncloud.c
+++ b/csync/src/csync_owncloud.c
@@ -62,37 +62,19 @@ int _connected = 0;                   /* flag to indicate if a connection exists
 
 
 void *_userdata;
-long long chunked_total_size = 0;
-long long chunked_done = 0;
 
 struct listdir_context *propfind_cache = 0;
 
 bool is_first_propfind = true;
 
-
-struct resource* _stat_cache = 0;
-/* id cache, cache the ETag: header of a GET request */
-struct { char *uri; char *id;  } _id_cache = { NULL, NULL };
-
 static void clean_caches() {
     clear_propfind_recursive_cache();
 
     free_fetchCtx(propfind_cache);
     propfind_cache = NULL;
-
-    resource_free(_stat_cache);
-    _stat_cache = NULL;
-
-    SAFE_FREE(_id_cache.uri);
-    SAFE_FREE(_id_cache.id);
 }
 
 
-
-#define PUT_BUFFER_SIZE 1024*5
-
-char _buffer[PUT_BUFFER_SIZE];
-
 /*
  * helper method to build up a user text for SSL problems, called from the
  * verify_sslcert callback.
@@ -765,77 +747,6 @@ static struct listdir_context *fetch_resource_list_attempts(const char *uri, int
 
 
 /*
- * file functions
- */
-int owncloud_stat(const char *uri, csync_vio_file_stat_t *buf) {
-    /* get props:
-     *   modtime
-     *   creattime
-     *   size
-     */
-    struct listdir_context  *fetchCtx = NULL;
-    char *decodedUri = NULL;
-    int len = 0;
-    errno = 0;
-
-    ne_uri uri_parsed;
-    if (ne_uri_parse(uri, &uri_parsed) != NE_OK) {
-        return 1;
-    }
-
-    buf->name = c_basename(uri);
-
-    if( _stat_cache && _stat_cache->uri && strcmp( uri_parsed.path, _stat_cache->uri ) == 0 ) {
-        ne_uri_free(&uri_parsed);
-        resourceToFileStat(buf, _stat_cache );
-        return 0;
-    }
-    ne_uri_free(&uri_parsed);
-    DEBUG_WEBDAV("owncloud_stat => Could not find in stat cache %s", uri);
-
-    /* fetch data via a propfind call. */
-    /* fetchCtx = fetch_resource_list( uri, NE_DEPTH_ONE); */
-    fetchCtx = fetch_resource_list_attempts( uri, NE_DEPTH_ONE);
-    DEBUG_WEBDAV("=> Errno after fetch resource list for %s: %d", uri, errno);
-    if (!fetchCtx) {
-        return -1;
-    }
-
-    if( fetchCtx ) {
-        struct resource *res = fetchCtx->list;
-        while( res ) {
-            /* remove trailing slashes */
-            len = strlen(res->uri);
-            while( len > 0 && res->uri[len-1] == '/' ) --len;
-            decodedUri = ne_path_unescape( fetchCtx->target ); /* allocates memory */
-
-            /* Only do the comparaison of the part of the string without the trailing
-               slashes, and make sure decodedUri is not too large */
-            if( strncmp(res->uri, decodedUri, len ) == 0 && decodedUri[len] == '\0') {
-                SAFE_FREE( decodedUri );
-                break;
-            }
-            res = res->next;
-            SAFE_FREE( decodedUri );
-        }
-        if( res ) {
-            DEBUG_WEBDAV("Working on file %s", res->name );
-        } else {
-            DEBUG_WEBDAV("ERROR: Result struct not valid!");
-        }
-
-        // Fill user-provided buffer
-        resourceToFileStat(buf, res );
-
-        free_fetchCtx( fetchCtx );
-    }
-    DEBUG_WEBDAV("STAT result from propfind: %s, mtime: %llu", buf->name ? buf->name:"NULL",
-                    (unsigned long long) buf->mtime );
-
-    return 0;
-}
-
-/*
  * directory functions
  */
 csync_vio_handle_t *owncloud_opendir(const char *uri) {
@@ -919,16 +830,6 @@ csync_vio_file_stat_t *owncloud_readdir(csync_vio_handle_t *dhandle) {
             csync_vio_file_stat_t* lfs = csync_vio_file_stat_new();
             resourceToFileStat(lfs, currResource);
 
-            // Save the current readdir result into our single item stat cache too so a call to stat()
-            // will return that item
-            if (_stat_cache) {
-                resource_free(_stat_cache);
-                _stat_cache = NULL;
-            }
-            _stat_cache = resource_dup(currResource);
-            _stat_cache->next = 0;
-
-
             SAFE_FREE( escaped_path );
             return lfs;
         }
diff --git a/csync/src/csync_owncloud.h b/csync/src/csync_owncloud.h
index d6bce75..152a2d9 100644
--- a/csync/src/csync_owncloud.h
+++ b/csync/src/csync_owncloud.h
@@ -172,7 +172,6 @@ struct resource* resource_dup(struct resource* o);
 csync_vio_handle_t *owncloud_opendir(const char *uri);
 csync_vio_file_stat_t *owncloud_readdir(csync_vio_handle_t *dhandle);
 int owncloud_closedir(csync_vio_handle_t *dhandle);
-int owncloud_stat(const char *uri, csync_vio_file_stat_t *buf);
 int owncloud_commit(void);
 char *owncloud_error_string(void);
 void owncloud_init(void *userdata);
diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c
index 44d1a03..95c5c0d 100644
--- a/csync/src/csync_update.c
+++ b/csync/src/csync_update.c
@@ -584,11 +584,14 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
         continue;
     }
 
-    /* == see if really stat has to be called. */
-    /* FIXME: No, this stat() is actually useless. This is the only place where we call it
-       and we get all info already thanks to csync_vio_readdir */
-    fs = csync_vio_file_stat_new();
-    res = csync_vio_stat(ctx, filename, fs);
+    /* Only for the local replica we have to stat(), for the remote one we have all data already */
+    if (ctx->replica == LOCAL_REPLICA) {
+        fs = csync_vio_file_stat_new();
+        res = csync_vio_stat(ctx, filename, fs);
+    } else {
+        fs = dirent;
+        res = 0;
+    }
 
     if( res == 0) {
       switch (fs->type) {
@@ -643,7 +646,10 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
         previous_fs->child_modified = ctx->current_fs->child_modified;
     }
 
-    csync_vio_file_stat_destroy(fs);
+    /* Only for the local replica we have to destroy stat(), for the remote one it is a pointer to dirent */
+    if (ctx->replica == LOCAL_REPLICA) {
+        csync_vio_file_stat_destroy(fs);
+    }
 
     if (rc < 0) {
       if (CSYNC_STATUS_IS_OK(ctx->status_code)) {
diff --git a/csync/src/vio/csync_vio.c b/csync/src/vio/csync_vio.c
index fa7f74b..282c8de 100644
--- a/csync/src/vio/csync_vio.c
+++ b/csync/src/vio/csync_vio.c
@@ -106,7 +106,7 @@ int csync_vio_stat(CSYNC *ctx, const char *uri, csync_vio_file_stat_t *buf) {
 
   switch(ctx->replica) {
     case REMOTE_REPLICA:
-      rc = owncloud_stat(uri, buf);
+      CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "ERROR: Cannot call remote stat, not implemented");
       break;
     case LOCAL_REPLICA:
       rc = csync_vio_local_stat(uri, buf);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list