Daniel,
On 11.04.2013 12:05, Daniel Gruno wrote:
Thanks for fixing the stat function
well, another possible fix would be this one:
Index: modules/lua/lua_request.c
===================================================================
--- modules/lua/lua_request.c (revision 1466743)
+++ modules/lua/lua_request.c (working copy)
@@ -1204,19 +1204,19 @@
luaL_checktype(L, 2, LUA_TSTRING);
r = ap_lua_check_request_rec(L, 1);
filename = lua_tostring(L, 2);
- if (apr_stat(&file_info, filename, APR_FINFO_NORM, r->pool) == OK) {
+ if (apr_stat(&file_info, filename, APR_FINFO_MIN, r->pool) == OK) {
lua_newtable(L);
lua_pushstring(L, "mtime");
- lua_pushinteger(L, (ptrdiff_t)(file_info.mtime / 1000000));
+ lua_pushnumber(L, file_info.mtime);
lua_settable(L, -3);
lua_pushstring(L, "atime");
- lua_pushinteger(L, (ptrdiff_t)(file_info.atime / 1000000));
+ lua_pushnumber(L, file_info.atime);
lua_settable(L, -3);
lua_pushstring(L, "ctime");
- lua_pushinteger(L, (ptrdiff_t)(file_info.ctime / 1000000));
+ lua_pushnumber(L, file_info.ctime);
lua_settable(L, -3);
lua_pushstring(L, "size");
this way we bring the higher resolution of the time values into Lua;
however I've not yet checked if there are platforms which really provide
mtime/atime/ctime with a better resolution than 1 second;
if there are then it makes probably sense for the above patch, and then
do the divide if needed within the Lua scripts like:
local mtime = os.date(fmt, math.floor(info.mtime / 1000000))
r:puts( ("%s was last modified at: %s\n"):format(r.filename, mtime) )
since there might be usage cases for the time values other than feeding
os.date() for displaying, f.e. a simple compare; and one second is long ;-)
comments welcome!
add_version_component does indeed seem to be missing - unsure whether we
really need it or not, so I'll just comment it out in the docs for now.
not sure either - but it was there, so I did test it.
Gün.