only call device/get_status every 60 seconds (hardcoded for now)

This commit is contained in:
josch
2014-12-29 22:10:41 +01:00
parent 3b8ecf3bac
commit 02e2eec1d4
3 changed files with 12 additions and 4 deletions

View File

@@ -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);

View File

@@ -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;
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)) {

View File

@@ -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;