mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 10:20:29 +00:00
Fix StoreAsset update for existing assets in redbean
This commit is contained in:
parent
d6a039821f
commit
1526116192
1 changed files with 7 additions and 3 deletions
|
@ -3303,11 +3303,15 @@ static int LuaStoreAsset(lua_State *L) {
|
||||||
oldcdirsize = GetZipCdirSize(zcdir);
|
oldcdirsize = GetZipCdirSize(zcdir);
|
||||||
oldcdiroffset = GetZipCdirOffset(zcdir);
|
oldcdiroffset = GetZipCdirOffset(zcdir);
|
||||||
if (a) {
|
if (a) {
|
||||||
|
// to remove an existing asset,
|
||||||
|
// first copy the central directory part before its record
|
||||||
v[4].iov_base = zbase + oldcdiroffset;
|
v[4].iov_base = zbase + oldcdiroffset;
|
||||||
v[4].iov_len = a->cf - oldcdiroffset;
|
v[4].iov_len = a->cf - oldcdiroffset;
|
||||||
v[5].iov_base = zbase + oldcdiroffset + ZIP_CFILE_HDRSIZE(zbase + a->cf);
|
// and then the rest of the central directory
|
||||||
v[5].iov_len =
|
v[5].iov_base = zbase + oldcdiroffset +
|
||||||
oldcdirsize - v[4].iov_len - ZIP_CFILE_HDRSIZE(zbase + a->cf);
|
(v[4].iov_len + ZIP_CFILE_HDRSIZE(zbase + a->cf));
|
||||||
|
v[5].iov_len = oldcdirsize -
|
||||||
|
(v[4].iov_len + ZIP_CFILE_HDRSIZE(zbase + a->cf));
|
||||||
} else {
|
} else {
|
||||||
v[4].iov_base = zbase + oldcdiroffset;
|
v[4].iov_base = zbase + oldcdiroffset;
|
||||||
v[4].iov_len = oldcdirsize;
|
v[4].iov_len = oldcdirsize;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue