OSDN Git Service

use modification time instead of MD5 sum
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 21 Oct 2018 05:54:12 +0000 (14:54 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 21 Oct 2018 05:54:12 +0000 (14:54 +0900)
src/ltj-jfont.lua

index 5f1ddf6..91ff794 100644 (file)
@@ -933,19 +933,19 @@ end
 
 --
 do
-   local cache_ver = 15
-   local checksum = file.checksum
+   local cache_ver = 16
 
    local function prepare_extra_data_base(id)
       if (not id) or (not id.filename) then return end
       local bname = id.psname or file.nameonly(id.filename)
       if not font_extra_basename[bname] then
         -- if the cache is present, read it
-        local newsum = checksum(id.filename) -- MD5 checksum of the fontfile
+        if not lfs then lfs=require"lfs"  end
+        local newtime = lfs.attributes(id.filename,"modification")
         local v = "extra_" .. string.lower(bname)
         local dat = ltjb.load_cache(
            v,
-           function (t) return (t.version~=cache_ver) or (t.chksum~=newsum) end
+           function (t) return (t.version~=cache_ver) or (t.modtime~=newtime) end
         )
         -- if the cache is not found or outdated, save the cache
         if dat then
@@ -957,7 +957,7 @@ do
            font_extra_basename[bname] = dat or {}
            ltjb.save_cache( v,
                             {
-                               chksum = newsum,
+                               modtime = newtime,
                                version = cache_ver,
                                dat,
                             })