Skip to content

Commit

Permalink
use tag name for features, use correct urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Sequal32 committed Nov 11, 2020
1 parent b25e8db commit 0d51195
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src-tauri/src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ use zip::ZipArchive;

use crate::util::{Error, Features};

// const LATEST_RELEASE_URL: &str = "https://api.github.com/repositories/290448187/releases/latest";
const LATEST_RELEASE_URL: &str = "http://localhost:8000/release.json";
const FEATURES_URL: &str = "http://localhost:8000/features.json";

const LATEST_RELEASE_URL: &str = "https://api.github.com/repos/sequal32/yourcontrols/releases/latest";
const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0";

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ReleaseData {
pub download_url: String,
pub date: i64,
pub name: String
pub tag_name: String
}

pub struct Downloader {
Expand Down Expand Up @@ -52,7 +49,7 @@ impl Downloader {
ReleaseData {
download_url: asset_data["browser_download_url"].as_str()?.to_string(),
date: time,
name: data["name"].as_str()?.to_string(),
tag_name: data["tag_name"].as_str()?.to_string(),
}
)
}
Expand Down Expand Up @@ -98,7 +95,12 @@ impl Downloader {
}

pub fn get_features(&self) -> Result<Features, Error> {
let response = match self.get_url(FEATURES_URL) {
let tag_name = match self.latest_release.as_ref() {
Some(d) => &d.tag_name,
None => return Err(Error::ReleaseError)
};

let response = match self.get_url(&format!("https://raw.githubusercontent.com/Sequal32/yourcontrols/{}/features.json", tag_name)) {
Ok(response) => response,
Err(e) => return Err(Error::WebError(e))
};
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ impl Installer {
format!("{}\\{}", self.program_dir, relative_path)
}
};

// Write dir
info!("Writing {}", full_path);
if file.is_dir() {

fs::create_dir(full_path).ok();
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class App extends React.Component {

this.setState({
currentDialog: {
title: args.releaseData.name,
title: "Release " + args.releaseData.tagName,
description: `Released on ${date.toDateString()}`,
buttonText: "OK",
},
Expand Down

0 comments on commit 0d51195

Please sign in to comment.