hazel
hazel copied to clipboard
Can't access update/win32/:version/RELEASES
Updating on MacOS works fine, but on Windows I get the error "Remote release File is empty or corrupted." I'm pretty sure that the error is because of not being able to access
We're having the same issue. Windows app won't update because of this.
I fixed this issue myself by updating the cacheReleaseList
function in the cache.js
file as follows:
async cacheReleaseList(url) {
const { token } = this.config;
const headers = { Accept: "application/vnd.github.preview" };
if (token && typeof token === "string" && token.length > 0) {
headers.Authorization = `token ${token}`;
}
const res = await retry(
async () => {
const response = await fetch(url, { headers });
let buffer = await response.buffer();
if (response.status !== 200) {
throw new Error(
`Tried to cache RELEASES, but failed fetching ${url}, status ${status}`
);
}
return await buffer.toString("utf-8");
},
{ retries: 3 }
);
const content = res;
const matches = content.match(/[^ ]*\.nupkg/gim);
if (matches.length === 0) {
throw new Error(
`Tried to cache RELEASES, but failed. RELEASES content doesn't contain nupkg`
);
}
const nuPKG = url.replace("RELEASES", matches[0]);
return content.replace(matches[0], nuPKG);
}
The response from Github API is an octet stream and needs to be buffered and then needs to be decoded using utf-8.
I hope this helps and the dev team adds it to the next update.
Hello, Was this ever fixed? It seems that I have the same issue and I don't know what to do. Thanks in advance!
Sharing what worked for me: https://github.com/vercel/hazel/issues/79#issuecomment-1010293920