Permalink
Browse files

Drop userdate for cache updates.

  • Loading branch information...
1 parent 92de4be commit 2d8c65c29c70816d9c41084c45ee69ba6b429fdb @davidstrauss davidstrauss committed Dec 14, 2012
Showing with 17 additions and 45 deletions.
  1. +17 −45 src/fusedav.c
View
@@ -310,46 +310,26 @@ char *strip_trailing_slash(char *fn, int *is_dir) {
return fn;
}
-static void getdir_propfind_callback(void *userdata, const ne_uri *u, const ne_prop_result_set *results) {
- struct fill_info *f = userdata;
- char fn[PATH_MAX], *t;
+static void getdir_propfind_callback(__unused void *userdata, const ne_uri *u, const ne_prop_result_set *results) {
+ char path[PATH_MAX];
int is_dir = 0;
struct fusedav_config *config = fuse_get_context()->private_data;
struct stat_cache_value value;
- char *cache_path = NULL;
bool is_deleted;
- //assert(f);
+ //log_print(LOG_DEBUG, "getdir_propfind_callback: %s", u->path);
- strncpy(fn, u->path, sizeof(fn));
- fn[sizeof(fn)-1] = 0;
- strip_trailing_slash(fn, &is_dir);
+ strncpy(path, u->path, PATH_MAX);
+ path[sizeof(path) - 1] = 0;
+ strip_trailing_slash(path, &is_dir);
fill_stat(&value.st, results, &is_deleted, is_dir);
value.prepopulated = false;
- if (strcmp(fn, f->root) && fn[0]) {
- //char *h;
- //log_print(LOG_DEBUG, "getdir_propfind_callback fn: %s", fn);
-
- if ((t = strrchr(fn, '/')))
- t++;
- else
- t = fn;
-
- asprintf(&cache_path, "%s/%s", f->root, t);
- //log_print(LOG_DEBUG, "getdir_propfind_callback cache_path: %s", cache_path);
- if (is_deleted)
- stat_cache_delete(config->cache, cache_path);
- else
- stat_cache_value_set(config->cache, cache_path, &value);
- free(cache_path);
-
- // Send the data to FUSE.
- //h = ne_path_unescape(t);
- //f->filler(f->buf, h, NULL, 0);
- //free(h);
- }
+ if (is_deleted)
+ stat_cache_delete(config->cache, path);
+ else
+ stat_cache_value_set(config->cache, path, &value);
}
static void getdir_cache_callback(
@@ -373,7 +353,7 @@ static void getdir_cache_callback(
free(h);
}
-static int update_directory(const char *path, bool attempt_progessive_update, void *userdata) {
+static int update_directory(const char *path, bool attempt_progessive_update) {
struct fusedav_config *config = fuse_get_context()->private_data;
bool needs_update = true;
ne_session *session;
@@ -392,7 +372,7 @@ static int update_directory(const char *path, bool attempt_progessive_update, vo
asprintf(&update_path, "%s?changes_since=%lu", path, last_updated - CLOCK_SKEW);
log_print(LOG_DEBUG, "Freshening directory data: %s", update_path);
- if (simple_propfind_with_redirect(session, update_path, NE_DEPTH_ONE, query_properties, getdir_propfind_callback, userdata) == NE_OK) {
+ if (simple_propfind_with_redirect(session, update_path, NE_DEPTH_ONE, query_properties, getdir_propfind_callback, NULL) == NE_OK) {
log_print(LOG_DEBUG, "Freshen PROPFIND success");
needs_update = false;
}
@@ -409,7 +389,7 @@ static int update_directory(const char *path, bool attempt_progessive_update, vo
log_print(LOG_DEBUG, "Replacing directory data: %s", path);
timestamp = time(NULL);
min_generation = stat_cache_get_local_generation();
- if (simple_propfind_with_redirect(session, path, NE_DEPTH_ONE, query_properties, getdir_propfind_callback, userdata) != NE_OK) {
+ if (simple_propfind_with_redirect(session, path, NE_DEPTH_ONE, query_properties, getdir_propfind_callback, NULL) != NE_OK) {
log_print(LOG_WARNING, "Complete PROPFIND failed: %s", ne_get_error(session));
return -ENOENT;
}
@@ -453,7 +433,7 @@ static int dav_readdir(
}
log_print(LOG_DEBUG, "Updating directory: %s", path);
- if (update_directory(path, (ret == -STAT_CACHE_OLD_DATA), &f) != 0) {
+ if (update_directory(path, (ret == -STAT_CACHE_OLD_DATA)) != 0) {
log_print(LOG_ERR, "Failed to update directory: %s", path);
return -1;
}
@@ -478,13 +458,11 @@ static void getattr_propfind_callback(void *userdata, const ne_uri *u, const ne_
strncpy(fn, u->path, sizeof(fn));
fn[sizeof(fn) - 1] = 0;
- if (debug)
- log_print(LOG_DEBUG, "getattr_propfind_callback: %s", fn);
+ //log_print(LOG_DEBUG, "getattr_propfind_callback: %s", fn);
strip_trailing_slash(fn, &is_dir);
- if (debug)
- log_print(LOG_DEBUG, "stripped: %s (isdir: %d)", fn, is_dir);
+ //log_print(LOG_DEBUG, "stripped: %s (isdir: %d)", fn, is_dir);
fill_stat(st, results, NULL, is_dir);
@@ -501,14 +479,8 @@ static int get_stat(const char *path, struct stat *stbuf) {
int is_dir = 0;
time_t parent_children_update_ts;
- struct fill_info f;
-
//log_print(LOG_DEBUG, "getdir(%s)", path);
- f.buf = NULL;
- f.filler = NULL;
- f.root = path_cvt(path);
-
memset(stbuf, 0, sizeof(struct stat));
log_print(LOG_DEBUG, "get_stat(%s, stbuf)", path);
@@ -554,7 +526,7 @@ static int get_stat(const char *path, struct stat *stbuf) {
// If the parent directory is out of date, update it.
if (parent_children_update_ts < (time(NULL) - STAT_CACHE_NEGATIVE_TTL)) {
log_print(LOG_DEBUG, "Updating directory: %s", parent_path);
- update_directory(parent_path, (parent_children_update_ts > 0), &f);
+ update_directory(parent_path, (parent_children_update_ts > 0));
}
// Try again to hit the file in the stat cache.

0 comments on commit 2d8c65c

Please sign in to comment.