From 02e2eec1d425765af4c5122003cf8737e8588009 Mon Sep 17 00:00:00 2001 From: josch Date: Mon, 29 Dec 2014 22:10:41 +0100 Subject: [PATCH] only call device/get_status every 60 seconds (hardcoded for now) --- fuse/main.c | 2 ++ fuse/operations.c | 12 ++++++++---- fuse/operations.h | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fuse/main.c b/fuse/main.c index 90a04fe..fe60d0a 100644 --- a/fuse/main.c +++ b/fuse/main.c @@ -454,6 +454,8 @@ int main(int argc, char *argv[]) ctx->sv_writefiles = stringv_alloc(); ctx->sv_readonlyfiles = stringv_alloc(); + ctx->last_status_check = 0; + ctx->interval_status_check = 60; ret = fuse_main(argc, argv, &mediafirefs_oper, ctx); diff --git a/fuse/operations.c b/fuse/operations.c index 69b263e..217ecd2 100644 --- a/fuse/operations.c +++ b/fuse/operations.c @@ -109,15 +109,19 @@ int mediafirefs_getattr(const char *path, struct stat *stbuf) * since getattr is called before every other call (except for getattr, * read and write) wee only call folder_tree_update in the getattr call * and not the others - * - * FIXME: only call folder_tree_update if it has not been called for a set - * amount of time */ struct mediafirefs_context_private *ctx; int retval; + time_t now; ctx = fuse_get_context()->private_data; - folder_tree_update(ctx->tree, ctx->conn, false); + + now = time(NULL); + if (now - ctx->last_status_check > ctx->interval_status_check) { + folder_tree_update(ctx->tree, ctx->conn, false); + ctx->last_status_check = now; + } + retval = folder_tree_getattr(ctx->tree, ctx->conn, path, stbuf); if (retval != 0 && stringv_mem(ctx->sv_writefiles, path)) { diff --git a/fuse/operations.h b/fuse/operations.h index 85e4657..0a0fb83 100644 --- a/fuse/operations.h +++ b/fuse/operations.h @@ -35,6 +35,8 @@ struct timespec; struct mediafirefs_context_private { mfconn *conn; folder_tree *tree; + time_t last_status_check; + time_t interval_status_check; char *configfile; char *dircache; char *filecache;