From 0573008c9c5e51263b04e55e83e0f49ecefa6e64 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 4 Aug 2023 23:35:02 +0000 Subject: [PATCH] Set some blob auto-delete option defaults on android only. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4383 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- core/core.js | 4 ++-- src/task.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/core.js b/core/core.js index 01c4f84b..02bb9d47 100644 --- a/core/core.js +++ b/core/core.js @@ -74,12 +74,12 @@ const k_global_settings = { }, blob_fetch_age_seconds: { type: 'integer', - default_value: undefined, + default_value: (platform() == 'android' ? 0.5 * 365 * 24 * 60 * 60 : undefined), description: 'Only blobs mentioned more recently than this age will be automatically fetched.', }, blob_expire_age_seconds: { type: 'integer', - default_value: undefined, + default_value: (platform() == 'android' ? 1.0 * 365 * 24 * 60 * 60 : undefined), description: 'Blobs older than this will be automatically deleted.', }, }; diff --git a/src/task.c b/src/task.c index 4c036378..e1f0a1b9 100644 --- a/src/task.c +++ b/src/task.c @@ -175,6 +175,7 @@ static bool _export_record_release(tf_task_t* task, export_record_t** export) } static JSValue _tf_task_version(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv); +static JSValue _tf_task_platform(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv); static JSValue _tf_task_get_parent(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv); static JSValue _tf_task_exit(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv); static JSValue _tf_task_trace(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv); @@ -694,6 +695,19 @@ static JSValue _tf_task_version(JSContext* context, JSValueConst this_val, int a return version; } +static JSValue _tf_task_platform(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv) +{ +#if defined(_WIN32) + return JS_NewString(context, "windows"); +#elif defined(__ANDROID__) + return JS_NewString(context, "android"); +#elif defined(__linux__) + return JS_NewString(context, "linux"); +#else + return JS_NewString(context, "other"); +#endif +} + exportid_t tf_task_export_function(tf_task_t* task, tf_taskstub_t* to, JSValue function) { export_record_t* export = NULL; @@ -1725,6 +1739,7 @@ void tf_task_activate(tf_task_t* task) tf_util_register(context); JS_SetPropertyStr(context, global, "exit", JS_NewCFunction(context, _tf_task_exit, "exit", 1)); JS_SetPropertyStr(context, global, "version", JS_NewCFunction(context, _tf_task_version, "version", 0)); + JS_SetPropertyStr(context, global, "platform", JS_NewCFunction(context, _tf_task_platform, "platform", 0)); JS_SetPropertyStr(context, global, "getFile", JS_NewCFunction(context, _tf_task_getFile, "getFile", 1)); JS_FreeValue(context, global); }