Skip to content

Commit

Permalink
Make server fall back to resolving deps for missing snapshots when ex…
Browse files Browse the repository at this point in the history
…porting zips

Server-side version of luvit#249 / 5c75c68

Fixes luvit#248 and most of luvit#247 without having to update the lit client
  • Loading branch information
squeek502 committed Mar 13, 2019
1 parent 5c75c68 commit 64b5ec6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions libs/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,25 @@ return function (db, prefix)
end

-- Use snapshot if there is one
local snapshotExists = false
if meta.snapshot then
hash = meta.snapshot
else
snapshotExists = pcall(function() db.loadAny(meta.snapshot) end)
if snapshotExists then
hash = meta.snapshot
end
end

if not snapshotExists then
local deps = {}
calculateDeps(db, deps, meta.dependencies)
hash = installDeps(db, hash, deps)
end

-- Make sure the resolved snapshot hash matches
if not snapshotExists then
assert(hash == meta.snapshot, "Snapshot missing and resolved snapshot hash differs from existing hash (hash="..meta.snapshot..", resolved="..hash..")")
end

local zip = exportZip(db, hash)
local filename = meta.name:match("[^/]+$") .. "-v" .. meta.version .. ".zip"

Expand Down

0 comments on commit 64b5ec6

Please sign in to comment.