Skip to content
Browse files

Fix deleting items in a directory affecting the containing directory.

  • Loading branch information...
1 parent 95bb0d3 commit 53c29e7a42b3503454014165a0f7a23db96becd7 @davidstrauss davidstrauss committed
Showing with 18 additions and 20 deletions.
  1. +6 −8 src/fusedav.c
  2. +12 −12 src/statcache.c
View
14 src/fusedav.c
@@ -424,7 +424,7 @@ static int dav_readdir(
path = path_cvt(path);
- //log_print(LOG_DEBUG, "getdir(%s)", path);
+ log_print(LOG_DEBUG, "readdir(%s)", path);
f.buf = buf;
f.filler = filler;
@@ -489,11 +489,9 @@ static int get_stat(const char *path, struct stat *stbuf) {
int is_dir = 0;
time_t parent_children_update_ts;
- //log_print(LOG_DEBUG, "getdir(%s)", path);
-
memset(stbuf, 0, sizeof(struct stat));
- //log_print(LOG_DEBUG, "get_stat(%s, stbuf)", path);
+ log_print(LOG_DEBUG, "get_stat(%s, stbuf)", path);
if (!(session = session_get(1))) {
memset(stbuf, 0, sizeof(struct stat));
@@ -547,6 +545,8 @@ static int get_stat(const char *path, struct stat *stbuf) {
return stbuf->st_mode == 0 ? -ENOENT : 0;
}
+ log_print(LOG_DEBUG, "Missed updated cache: %s", path);
+
// If it's still not found, return that it doesn't exist.
memset(stbuf, 0, sizeof(struct stat));
return -ENOENT;
@@ -557,7 +557,7 @@ static int dav_getattr(const char *path, struct stat *stbuf) {
int r;
path = path_cvt(path);
- //log_print(LOG_DEBUG, "getattr(%s)", path);
+ log_print(LOG_DEBUG, "getattr(%s)", path);
r = get_stat(path, stbuf);
// Zero-out unused nanosecond fields.
@@ -585,8 +585,7 @@ static int dav_unlink(const char *path) {
path = path_cvt(path);
- if (debug)
- log_print(LOG_DEBUG, "unlink(%s)", path);
+ log_print(LOG_DEBUG, "unlink(%s)", path);
if (!(session = session_get(1)))
return -EIO;
@@ -604,7 +603,6 @@ static int dav_unlink(const char *path) {
ldb_filecache_delete(config->cache, path);
stat_cache_delete(config->cache, path);
- stat_cache_delete_parent(config->cache, path);
return 0;
}
View
24 src/statcache.c
@@ -173,7 +173,7 @@ struct stat_cache_value *stat_cache_value_get(stat_cache_t *cache, const char *p
key = path2key(path, false);
- //log_print(LOG_DEBUG, "CGET: %s", key);
+ log_print(LOG_DEBUG, "CGET: %s", key);
options = leveldb_readoptions_create();
value = (struct stat_cache_value *) leveldb_get(cache, options, key, strlen(key) + 1, &vallen, &errptr);
@@ -189,8 +189,7 @@ struct stat_cache_value *stat_cache_value_get(stat_cache_t *cache, const char *p
}
if (!value) {
- if (debug)
- log_print(LOG_DEBUG, "stat_cache_value_get miss on path: %s", path);
+ log_print(LOG_DEBUG, "stat_cache_value_get miss on path: %s", path);
return NULL;
}
@@ -207,7 +206,7 @@ struct stat_cache_value *stat_cache_value_get(stat_cache_t *cache, const char *p
time_t directory_updated;
int is_dir;
- //log_print(LOG_DEBUG, "Stat entry %s is %lu seconds old.", path, current_time - value->updated);
+ log_print(LOG_DEBUG, "Stat entry %s is %lu seconds old.", path, current_time - value->updated);
// If that's too old, check the last update of the directory.
directory = strip_trailing_slash(ne_path_parent(path), &is_dir);
@@ -299,9 +298,8 @@ int stat_cache_value_set(stat_cache_t *cache, const char *path, struct stat_cach
value->local_generation = stat_cache_get_local_generation();
key = path2key(path, false);
- //if (debug)
- //log_print(LOG_DEBUG, "CSET: %s (mode %04o)", key, value->st.st_mode);
- //print_stat(&value->st, "CSET");
+ log_print(LOG_DEBUG, "CSET: %s (mode %04o)", key, value->st.st_mode);
+ //print_stat(&value->st, "CSET");
options = leveldb_writeoptions_create();
leveldb_put(cache, options, key, strlen(key) + 1, (char *) value, sizeof(struct stat_cache_value), &errptr);
@@ -327,6 +325,9 @@ int stat_cache_delete(stat_cache_t *cache, const char *path) {
char *errptr = NULL;
key = path2key(path, false);
+
+ log_print(LOG_DEBUG, "CDEL: %s", key);
+
options = leveldb_writeoptions_create();
leveldb_delete(cache, options, key, strlen(key) + 1, &errptr);
leveldb_writeoptions_destroy(options);
@@ -485,8 +486,7 @@ int stat_cache_enumerate(stat_cache_t *cache, const char *path_prefix, void (*f)
time_t timestamp;
time_t current_time;
- //if (debug)
- // log_print(LOG_DEBUG, "stat_cache_enumerate(%s)", path_prefix);
+ log_print(LOG_DEBUG, "stat_cache_enumerate(%s)", path_prefix);
//stat_cache_list_all(cache, path_prefix);
if (!force) {
@@ -508,15 +508,15 @@ int stat_cache_enumerate(stat_cache_t *cache, const char *path_prefix, void (*f)
//log_print(LOG_DEBUG, "iterator initialized with prefix: %s", iter->key_prefix);
while ((entry = stat_cache_iter_current(iter))) {
- //log_print(LOG_DEBUG, "key: %s", entry->key);
- //log_print(LOG_DEBUG, "fn: %s", entry->key + iter->key_prefix_len);
+ log_print(LOG_DEBUG, "key: %s", entry->key);
+ log_print(LOG_DEBUG, "fn: %s", entry->key + iter->key_prefix_len);
f(path_prefix, entry->key + iter->key_prefix_len, user);
++found_entries;
free(entry);
stat_cache_iter_next(iter);
}
stat_cache_iterator_free(iter);
- //log_print(LOG_DEBUG, "Done iterating: %u items.", found_entries);
+ log_print(LOG_DEBUG, "Done iterating: %u items.", found_entries);
if (found_entries == 0)
return -STAT_CACHE_NO_DATA;

0 comments on commit 53c29e7

Please sign in to comment.
Something went wrong with that request. Please try again.