summaryrefslogtreecommitdiff
path: root/tex/context/base/l-md5.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2012-06-05 09:16:00 +0200
committerHans Hagen <pragma@wxs.nl>2012-06-05 09:16:00 +0200
commit1cbef76ff4aa6cc1f7dc1d38c4b0514e94ad59a5 (patch)
treef825c9515b1d51e48dddd9a3bc0d0c51c6b407ed /tex/context/base/l-md5.lua
parentc3efc6042c5a5a4d0f1a80bc3a097f0ae2963f7c (diff)
downloadcontext-1cbef76ff4aa6cc1f7dc1d38c4b0514e94ad59a5.tar.gz
beta 2012.06.05 09:16
Diffstat (limited to 'tex/context/base/l-md5.lua')
-rw-r--r--tex/context/base/l-md5.lua33
1 files changed, 24 insertions, 9 deletions
diff --git a/tex/context/base/l-md5.lua b/tex/context/base/l-md5.lua
index 1d471c966..6abf2e17d 100644
--- a/tex/context/base/l-md5.lua
+++ b/tex/context/base/l-md5.lua
@@ -31,15 +31,30 @@ if not md5.dec then function md5.dec(str) return convert(str,"%03i") end end
--~ function md5.dec(str) return (gsub(md5.sum(str),".",remap)) end
--~ end
-function file.needs_updating(oldname,newname,threshold) -- size modification access change
- local oldtime = lfs.attributes(oldname, modification)
- local newtime = lfs.attributes(newname, modification)
- if newtime >= oldtime then
- return false
- elseif oldtime - newtime < (threshold or 1) then
- return false
+function file.needsupdating(oldname,newname,threshold) -- size modification access change
+ local oldtime = lfs.attributes(oldname,"modification")
+ if oldtime then
+ local newtime = lfs.attributes(newname,"modification")
+ if not newtime then
+ return true -- no new file, so no updating needed
+ elseif newtime >= oldtime then
+ return false -- new file definitely needs updating
+ elseif oldtime - newtime < (threshold or 1) then
+ return false -- new file is probably still okay
+ else
+ return true -- new file has to be updated
+ end
else
- return true
+ return false -- no old file, so no updating needed
+ end
+end
+
+file.needs_updating = file.needsupdating
+
+function file.syncmtimes(oldname,newname)
+ local oldtime = lfs.attributes(oldname,"modification")
+ if oldtime and lfs.isfile(newname) then
+ lfs.touch(newname,oldtime,oldtime)
end
end
@@ -61,7 +76,7 @@ function file.loadchecksum(name)
return nil
end
-function file.savechecksum(name, checksum)
+function file.savechecksum(name,checksum)
if not checksum then checksum = file.checksum(name) end
if checksum then
io.savedata(name .. ".md5",checksum)