mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-16 15:17:21 -05:00
changed electron to tauri v2
This commit is contained in:
@@ -15,22 +15,29 @@ function isAllowedHost(url) {
|
||||
}
|
||||
|
||||
class UpdateClient {
|
||||
constructor(appDataPath) {
|
||||
constructor(appDataPath, token = null) {
|
||||
this.appDataPath = appDataPath;
|
||||
this.token = token || process.env.GITLAB_TOKEN || process.env.VYLA_GITLAB_TOKEN || null;
|
||||
}
|
||||
|
||||
fetchJson(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const urlObj = new URL(url);
|
||||
const headers = {
|
||||
'User-Agent': 'VylaHome-Client',
|
||||
'Accept': 'application/json'
|
||||
};
|
||||
|
||||
if (this.token) {
|
||||
headers['PRIVATE-TOKEN'] = this.token;
|
||||
}
|
||||
|
||||
const requestOptions = {
|
||||
hostname: urlObj.hostname,
|
||||
port: 443,
|
||||
path: urlObj.pathname + urlObj.search,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'User-Agent': 'VylaHome-Client',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
headers
|
||||
};
|
||||
|
||||
const req = https.request(requestOptions, (res) => {
|
||||
@@ -68,14 +75,20 @@ class UpdateClient {
|
||||
}
|
||||
|
||||
const urlObj = new URL(requestUrl);
|
||||
const headers = {
|
||||
'User-Agent': 'VylaHome-Client',
|
||||
'Accept': 'application/octet-stream'
|
||||
};
|
||||
|
||||
if (this.token) {
|
||||
headers['PRIVATE-TOKEN'] = this.token;
|
||||
}
|
||||
|
||||
const requestOptions = {
|
||||
hostname: urlObj.hostname,
|
||||
port: 443,
|
||||
path: urlObj.pathname + urlObj.search,
|
||||
headers: {
|
||||
'User-Agent': 'VylaHome-Client',
|
||||
'Accept': 'application/octet-stream'
|
||||
}
|
||||
headers
|
||||
};
|
||||
|
||||
const req = https.get(requestOptions, (res) => {
|
||||
@@ -142,14 +155,20 @@ class UpdateClient {
|
||||
}
|
||||
|
||||
const urlObj = new URL(requestUrl);
|
||||
const headers = {
|
||||
'User-Agent': 'VylaHome-Client',
|
||||
'Accept': 'application/octet-stream'
|
||||
};
|
||||
|
||||
if (this.token) {
|
||||
headers['PRIVATE-TOKEN'] = this.token;
|
||||
}
|
||||
|
||||
const requestOptions = {
|
||||
hostname: urlObj.hostname,
|
||||
port: 443,
|
||||
path: urlObj.pathname + urlObj.search,
|
||||
headers: {
|
||||
'User-Agent': 'VylaHome-Client',
|
||||
'Accept': 'application/octet-stream'
|
||||
}
|
||||
headers
|
||||
};
|
||||
|
||||
const req = https.get(requestOptions, (res) => {
|
||||
@@ -189,15 +208,15 @@ class UpdateClient {
|
||||
async checkForUpdates() {
|
||||
const releases = await this.fetchJson(RELEASES_API);
|
||||
if (!releases || releases.length === 0) {
|
||||
throw new Error('No releases found.');
|
||||
return null;
|
||||
}
|
||||
const release = releases[0];
|
||||
|
||||
const payloadAsset = (release.assets.links || []).find(a => a.name === 'update-payload.zip');
|
||||
const manifestAsset = (release.assets.links || []).find(a => a.name === 'manifest.json');
|
||||
const payloadAsset = (release.assets && release.assets.links ? release.assets.links : []).find(a => a.name === 'update-payload.zip');
|
||||
const manifestAsset = (release.assets && release.assets.links ? release.assets.links : []).find(a => a.name === 'manifest.json');
|
||||
|
||||
if (!payloadAsset) {
|
||||
throw new Error('No update-payload.zip asset found on latest release.');
|
||||
return null;
|
||||
}
|
||||
|
||||
let sha256 = null;
|
||||
|
||||
Reference in New Issue
Block a user