aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2024-03-12 21:02:15 -0400
committerAdam Harrison <adamdharrison@gmail.com>2024-03-12 21:02:15 -0400
commitf677376167b401b2c8f9154ac30fcd21b8aff238 (patch)
tree653bdd9a05abaca01808f11799a00d43679921c0 /src
parenta2be4feb021023408f19829b56219a21da2a2e07 (diff)
downloadlite-xl-plugin-manager-f677376167b401b2c8f9154ac30fcd21b8aff238.tar.gz
lite-xl-plugin-manager-f677376167b401b2c8f9154ac30fcd21b8aff238.zip
Fixed minor issue.
Diffstat (limited to 'src')
-rw-r--r--src/lpm.c12
-rw-r--r--src/lpm.lua2
2 files changed, 7 insertions, 7 deletions
diff --git a/src/lpm.c b/src/lpm.c
index 74c6a6a..fef74cc 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -1222,9 +1222,8 @@ static int lpm_get(lua_State* L) {
memmove(buffer, &buffer[to_write], buffer_length);
}
if (chunk_written == chunk_length) {
- if (!chunked) {
+ if (!chunked)
goto finish;
- }
if (buffer_length >= 2) {
if (!strnstr_local(buffer, "\r\n", 2)) {
snprintf(err, sizeof(err), "invalid end to chunk for %s%s", hostname, rest);
@@ -1237,13 +1236,14 @@ static int lpm_get(lua_State* L) {
}
}
if (chunk_length > 0) {
- buffer_length = lpm_socket_read(s, buffer, imin(sizeof(buffer), chunk_length - chunk_written + (chunked ? 2 : 0)), ssl_ctx);
- if ((!ssl_ctx && buffer_length == 0) || (ssl_ctx && content_length == -1 && buffer_length == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY))
+ int length = lpm_socket_read(s, &buffer[buffer_length], imin(sizeof(buffer) - buffer_length, chunk_length - chunk_written + (chunked ? 2 : 0)), ssl_ctx);
+ if ((!ssl_ctx && length == 0) || (ssl_ctx && content_length == -1 && length == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY))
goto finish;
- if (buffer_length <= 0) {
- mbedtls_snprintf(ssl_ctx ? 1 : 0, err, sizeof(err), ssl_ctx ? buffer_length : errno, "error retrieving full chunk for %s%s", hostname, rest);
+ if (length <= 0) {
+ mbedtls_snprintf(ssl_ctx ? 1 : 0, err, sizeof(err), ssl_ctx ? length : errno, "error retrieving full chunk for %s%s", hostname, rest);
goto cleanup;
}
+ buffer_length += length;
}
}
finish:
diff --git a/src/lpm.lua b/src/lpm.lua
index 83f833f..631f1ee 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -604,7 +604,7 @@ function common.get(source, options)
if headers.location then return common.get(headers.location, common.merge(options, { depth = (depth or 0) + 1 })) end
return res
end
- local cache_dir = checksum ~= "SKIP" and TMPDIR or (options.cache or CACHEDIR)
+ local cache_dir = checksum == "SKIP" and TMPDIR or (options.cache or CACHEDIR)
if not system.stat(cache_dir .. PATHSEP .. "files") then common.mkdirp(cache_dir .. PATHSEP .. "files") end
local cache_path = cache_dir .. PATHSEP .. "files" .. PATHSEP .. system.hash(checksum .. source)
if checksum ~= "SKIP" and system.stat(cache_path) and system.hash(cache_path, "file") ~= checksum then common.rmrf(cache_path) end