summaryrefslogtreecommitdiff
path: root/tex/context/base/core-uti.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2013-03-29 00:40:15 +0200
committerMarius <mariausol@gmail.com>2013-03-29 00:40:15 +0200
commitfa51b91a9f43ae55493d28761caf397c1d27207f (patch)
treeaaadc5766d0093a2e21fc64ee6b4aa32ef5cc4d4 /tex/context/base/core-uti.lua
parent6580c0d6985f98e634f2081b00576a15201c536b (diff)
downloadcontext-fa51b91a9f43ae55493d28761caf397c1d27207f.tar.gz
beta 2013.03.28 23:10
Diffstat (limited to 'tex/context/base/core-uti.lua')
-rw-r--r--tex/context/base/core-uti.lua45
1 files changed, 29 insertions, 16 deletions
diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua
index bf8d2c207..96ccdca48 100644
--- a/tex/context/base/core-uti.lua
+++ b/tex/context/base/core-uti.lua
@@ -35,7 +35,8 @@ local report_passes = logs.reporter("job","passes")
job = job or { }
local job = job
-job.version = "1.21"
+job.version = 1.22 -- make sure we don't have old lua 5.1 hash leftovers
+job.packversion = 1.02 -- make sure we don't have old lua 5.1 hash leftovers
-- some day we will implement loading of other jobs and then we need
-- job.jobs
@@ -132,7 +133,7 @@ local packlist = {
-- "references", -- we need to rename of them as only one packs (not structures.lists.references)
}
-local jobpacker = packers.new(packlist,1.01)
+local jobpacker = packers.new(packlist,job.packversion) -- jump number when changs in hash
job.pack = true
-- job.pack = false
@@ -172,15 +173,21 @@ function job.save(filename) -- we could return a table but it can get pretty lar
end
local function load(filename)
- local okay, data = pcall(dofile,filename)
- if okay and type(data) == "table" then
- local jobversion = job.version
- local datacomment = data.comment
- local dataversion = datacomment and datacomment.version or "?"
- if dataversion ~= jobversion then
- report_passes("version mismatch: %s <> %s",dataversion,jobversion)
+ if lfs.isfile(filename) then
+ local okay, data = pcall(dofile,filename)
+ if okay and type(data) == "table" then
+ local jobversion = job.version
+ local datacomment = data.comment
+ local dataversion = datacomment and datacomment.version or "?"
+ if dataversion ~= jobversion then
+ report_passes("version mismatch: %s <> %s",dataversion,jobversion)
+ else
+ return data
+ end
else
- return data
+ os.remove(filename) -- probably a bad file
+ report_passes("removing stale job data file %a, restart job",filename)
+ os.exit(true) -- trigger second run
end
end
end
@@ -195,10 +202,14 @@ function job.load(filename)
local target = list[1]
local initializer = list[3]
local result = accesstable(target,utilitydata)
- packers.unpack(result,jobpacker,true)
- migratetable(target,mark(result))
- if type(initializer) == "function" then
- initializer(result)
+ local done = packers.unpack(result,jobpacker,true)
+ if done then
+ migratetable(target,mark(result))
+ if type(initializer) == "function" then
+ initializer(result)
+ end
+ else
+ report_passes("pack version mismatch")
end
end
end
@@ -216,8 +227,10 @@ function job.loadother(filename)
local list = savelist[l]
local target = list[1]
local result = accesstable(target,utilitydata)
- packers.unpack(result,jobpacker,true)
- migratetable(target,result,unpacked)
+ local done = packers.unpack(result,jobpacker,true)
+ if done then
+ migratetable(target,result,unpacked)
+ end
end
unpacked.job.packed = nil -- nicer in inspecting
return unpacked