Commit 623c49e4 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

File's meta-object's "size" and "time" properties reflect current values

Query the disk for file's current "size" and "time" values when get_list() or get() method is used with a "detail" level of >= DETAIL.NORMAL and the "check file existence" toggle option is enabled for this directory in SCFG.

I pondered and contemplated whether this configuration setting should be checked/applied here or in the various JS scripts (e.g. filelist.js) and decided here was best to provide the most uniform/expected behavior, even though there is a performance impact. If a script doesn't need/use these properties, they should probably be specifying the DETAIL.MIN (minimal) detail level in their queries anyway, which will then bypass these performance-impacting disk queries.
parent a466152f
Pipeline #2910 passed with stage
in 9 minutes and 38 seconds
......@@ -251,11 +251,17 @@ set_file_properties(JSContext *cx, JSObject* obj, file_t* f, enum file_detail de
if(!JS_DefineProperty(cx, obj, "cost", val, NULL, NULL, flags))
return false;
}
val = UINT_TO_JSVAL(f->idx.size);
if(is_valid_dirnum(scfg, f->dir) && (scfg->dir[f->dir]->misc & DIR_FCHK) && detail >= file_detail_normal)
val = DOUBLE_TO_JSVAL((double)getfilesize(scfg, f));
else
val = UINT_TO_JSVAL(f->idx.size);
if(!JS_DefineProperty(cx, obj, "size", val, NULL, NULL, flags))
return false;
val = UINT_TO_JSVAL(f->hdr.when_written.time);
if(is_valid_dirnum(scfg, f->dir) && (scfg->dir[f->dir]->misc & DIR_FCHK) && detail >= file_detail_normal)
val = DOUBLE_TO_JSVAL((double)getfiletime(scfg, f));
else
val = UINT_TO_JSVAL(f->hdr.when_written.time);
if(!JS_DefineProperty(cx, obj, "time", val, NULL, NULL, flags))
return false;
if(f->hdr.when_imported.time > 0 || detail > file_detail_metadata) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment