Skip to content

Commit 7654230

Browse files
committed
Revert "get metadata from cargo.toml"
This reverts commit a90bd69.
1 parent a90bd69 commit 7654230

File tree

3 files changed

+8
-44
lines changed

3 files changed

+8
-44
lines changed

Cargo.lock

+1-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ self_update = { git = "https://github.com/hacknus/self_update", features = ["arc
2727
tempfile = "3.15"
2828
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls", "http2"] }
2929
semver = "1.0.24"
30-
cargo_metadata = "0.19"
3130

3231
[build-dependencies]
3332
regex = "1.11"

src/update.rs

+7-27
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
use cargo_metadata::MetadataCommand;
21
use self_update::self_replace;
32
use self_update::update::Release;
43
use semver::Version;
54
use std::path::Path;
65
use std::{env, fs, io};
76

7+
const REPO_OWNER: &str = "hacknus";
8+
const REPO_NAME: &str = "serial-monitor-rust";
9+
const MACOS_APP_NAME: &str = "Serial Monitor.app";
10+
811
/// method to copy the complete directory `src` to `dest` but skipping the binary `binary_name`
912
/// since we have to use `self-replace` for that.
1013
fn copy_dir(src: &Path, dest: &Path, binary_name: &str) -> io::Result<()> {
@@ -35,17 +38,9 @@ fn copy_dir(src: &Path, dest: &Path, binary_name: &str) -> io::Result<()> {
3538

3639
/// Function to check for updates and return the latest one, if it is more recent than the current version
3740
pub fn check_update() -> Option<Release> {
38-
let metadata = MetadataCommand::new().exec().ok()?;
39-
let url = metadata.root_package()?.clone().homepage?;
40-
let parts: Vec<&str> = url.split('/').collect();
41-
let (repo_owner, repo_name) = if parts.len() >= 5 && parts[2] == "github.com" {
42-
(parts[3].to_string(), parts[4].to_string())
43-
} else {
44-
return None;
45-
};
4641
if let Ok(builder) = self_update::backends::github::ReleaseList::configure()
47-
.repo_owner(&repo_owner)
48-
.repo_name(&repo_name)
42+
.repo_owner(REPO_OWNER)
43+
.repo_name(REPO_NAME)
4944
.build()
5045
{
5146
if let Ok(releases) = builder.fetch() {
@@ -126,24 +121,9 @@ pub fn update(release: Release) -> Result<(), Box<dyn std::error::Error>> {
126121
// extracted archive, but we cannot just assume that the parent directory of the
127122
// currently running executable is equal to the app name - this is especially not
128123
// the case if we run the code with `cargo run`.
129-
130-
// Fetch the metadata of the current Cargo project
131-
let metadata = MetadataCommand::new().exec()?;
132-
133-
// Access the package metadata
134-
let mac_os_app_name = metadata
135-
.root_package()
136-
.ok_or("Unable to get cargo metadata!")?
137-
.metadata
138-
.get("bundle")
139-
.ok_or("Unable to get cargo bundle metadata!")?
140-
.get("name")
141-
.ok_or("Unable to get cargo bundle metadata name!")?
142-
.as_str()
143-
.unwrap();
144124
tmp_archive_dir
145125
.path()
146-
.join(format!("{}.app/Contents/MacOS/{}", mac_os_app_name, binary))
126+
.join(format!("{}/Contents/MacOS/{}", MACOS_APP_NAME, binary))
147127
} else if cfg!(target_os = "linux") {
148128
let binary = env::current_exe()?
149129
.file_name()

0 commit comments

Comments
 (0)