Skip to content

Commit

Permalink
Merge pull request #228 from AchetaGames/3.9.0
Browse files Browse the repository at this point in the history
3.8.3 release
  • Loading branch information
aknarts authored Jan 24, 2023
2 parents a8f8f10 + 05854e4 commit a07c459
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 115 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/configuration/exclude_paths.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
io.github.achetagames.epic_asset_manager
src/ui/widgets/sid_login/mod.rs
src/ui/widgets/sid_login/mod.rs
data/resources/ui/sid_login/sid.ui
2 changes: 1 addition & 1 deletion .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/checkout@v2

- name: Install Rust toolchain
uses: actions-rs/toolchain@stable #@v1
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "epic_asset_manager"
version = "3.8.2"
version = "3.8.3"
authors = ["Milan Stastny <[email protected]>"]
edition = "2021"
license-file = "LICENSE"
Expand All @@ -19,7 +19,7 @@ chrono = "0.4"
diesel = { version = "2.0.0", features = ["sqlite", "r2d2"] }
diesel_migrations = { version = "2.0.0", features = ["sqlite"] }
egs-api = "0.6"
env_logger = "0.9"
env_logger = "0.10.0"
fs2 = "0.4.3"
gtk4 = { version = "0.5", features = ["v4_8"] }
gtk-macros = "0.3"
Expand Down Expand Up @@ -50,5 +50,4 @@ open = "3"
ashpd = "0.3"
gettext-rs = { version = "0.7", features = ["gettext-system"] }
ghregistry = "^0.2"
git2 = "0.15"
secret-service = "2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@
<url type="donation">https://ko-fi.com/achetagames</url>
<content_rating type="oars-1.0"/>
<releases>
<release version="3.8.3" date="2023-01-24">
<description>
<p>Bug fixing</p>
<ul>
<li>Handle malformed uproject properly</li>
<li>Fix dependencies and remove git2 dependency</li>
</ul>
</description>
</release>
<release version="3.8.2" date="2022-11-15">
<description>
<p>Engine Install fix</p>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project('epic_asset_manager',
'rust',
version: '3.8.2',
version: '3.8.3',
license: 'MIT',
meson_version: '>= 0.59')

Expand Down
214 changes: 107 additions & 107 deletions src/models/engine_data.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use glib::clone;
use glib::ObjectExt;
use gtk4::{glib, prelude::*, subclass::prelude::*};
use log::{debug, info, warn};
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::io::Read;
Expand Down Expand Up @@ -97,9 +96,9 @@ mod imp {
branch: RefCell<Option<String>>,
updatable: RefCell<bool>,
has_branch: RefCell<bool>,
pub ueversion: RefCell<Option<super::UnrealVersion>>,
pub sender: gtk4::glib::Sender<super::Msg>,
pub receiver: RefCell<Option<gtk4::glib::Receiver<super::Msg>>>,
pub ueversion: RefCell<Option<UnrealVersion>>,
pub sender: glib::Sender<Msg>,
pub receiver: RefCell<Option<glib::Receiver<Msg>>>,
pub model: OnceCell<gtk4::gio::ListStore>,
pub position: OnceCell<u32>,
}
Expand All @@ -111,7 +110,7 @@ mod imp {
type Type = super::EngineData;

fn new() -> Self {
let (sender, receiver) = gtk4::glib::MainContext::channel(gtk4::glib::PRIORITY_DEFAULT);
let (sender, receiver) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
Self {
guid: RefCell::new(None),
path: RefCell::new(None),
Expand Down Expand Up @@ -140,10 +139,10 @@ mod imp {
self.instance().setup_messaging();
}

fn signals() -> &'static [gtk4::glib::subclass::Signal] {
static SIGNALS: once_cell::sync::Lazy<Vec<gtk4::glib::subclass::Signal>> =
fn signals() -> &'static [glib::subclass::Signal] {
static SIGNALS: once_cell::sync::Lazy<Vec<glib::subclass::Signal>> =
once_cell::sync::Lazy::new(|| {
vec![gtk4::glib::subclass::Signal::builder("finished")
vec![glib::subclass::Signal::builder("finished")
.flags(glib::SignalFlags::ACTION)
.build()]
});
Expand Down Expand Up @@ -306,73 +305,74 @@ impl EngineData {
self.emit_by_name::<()>("finished", &[]);
}

fn needs_repo_update(path: &str, sender: Option<gtk4::glib::Sender<Msg>>) -> bool {
#[cfg(target_os = "linux")]
{
if let Ok(repo) = git2::Repository::open(&path) {
let mut commit = git2::Oid::zero();
let mut branch = String::new();
if let Ok(head) = repo.head() {
if head.is_branch() {
commit = head.target().unwrap();
branch = head.name().unwrap().to_string();
if let Some(s) = sender.clone() {
s.send(Msg::Branch(
head.shorthand().unwrap_or_default().to_string(),
))
.unwrap();
}
}
}
let mut time = git2::Time::new(0, 0);
if let Ok(c) = repo.find_commit(commit) {
time = c.time();
}
if let Ok(remotes) = repo.remotes() {
let num_remotes = remotes.len();
for remote in remotes.iter().flatten() {
if let Ok(mut r) = repo.find_remote(remote) {
if num_remotes > 1 {
if let Some(url) = r.url() {
if !url.contains("EpicGames/UnrealEngine.git") {
continue;
}
}
}
let cb = Self::git_callbacks();
if let Err(e) = r.connect_auth(git2::Direction::Fetch, Some(cb), None) {
warn!("Unable to connect: {}", e);
}
if let Ok(list) = r.list() {
for head in list {
if branch.eq(&head.name()) {
if head.oid().eq(&commit) {
debug!("{} Up to date", path);
if let Some(s) = sender {
s.send(Msg::Update(false)).unwrap();
}
return false;
}
info!("{} needs updating", path);
debug!(
"{} Local commit {}({}), remote commit {}",
path,
commit,
time.seconds(),
head.oid()
);
if let Some(s) = sender {
s.send(Msg::Update(true)).unwrap();
}
return true;
}
}
}
}
}
}
};
}
fn needs_repo_update(_path: &str, _sender: Option<glib::Sender<Msg>>) -> bool {
// #[cfg(target_os = "linux")]
// This is disabled due to issues with git2 crate and constant need to rebuild if git lib gets updated
// {
// if let Ok(repo) = git2::Repository::open(&path) {
// let mut commit = git2::Oid::zero();
// let mut branch = String::new();
// if let Ok(head) = repo.head() {
// if head.is_branch() {
// commit = head.target().unwrap();
// branch = head.name().unwrap().to_string();
// if let Some(s) = sender.clone() {
// s.send(Msg::Branch(
// head.shorthand().unwrap_or_default().to_string(),
// ))
// .unwrap();
// }
// }
// }
// let mut time = git2::Time::new(0, 0);
// if let Ok(c) = repo.find_commit(commit) {
// time = c.time();
// }
// if let Ok(remotes) = repo.remotes() {
// let num_remotes = remotes.len();
// for remote in remotes.iter().flatten() {
// if let Ok(mut r) = repo.find_remote(remote) {
// if num_remotes > 1 {
// if let Some(url) = r.url() {
// if !url.contains("EpicGames/UnrealEngine.git") {
// continue;
// }
// }
// }
// let cb = Self::git_callbacks();
// if let Err(e) = r.connect_auth(git2::Direction::Fetch, Some(cb), None) {
// warn!("Unable to connect: {}", e);
// }
// if let Ok(list) = r.list() {
// for head in list {
// if branch.eq(&head.name()) {
// if head.oid().eq(&commit) {
// debug!("{} Up to date", path);
// if let Some(s) = sender {
// s.send(Msg::Update(false)).unwrap();
// }
// return false;
// }
// info!("{} needs updating", path);
// debug!(
// "{} Local commit {}({}), remote commit {}",
// path,
// commit,
// time.seconds(),
// head.oid()
// );
// if let Some(s) = sender {
// s.send(Msg::Update(true)).unwrap();
// }
// return true;
// }
// }
// }
// }
// }
// }
// };
// }
false
}

Expand Down Expand Up @@ -412,36 +412,36 @@ impl EngineData {
self.property("needs-update")
}

#[cfg(target_os = "linux")]
fn git_callbacks() -> git2::RemoteCallbacks<'static> {
let git_config = git2::Config::open_default().unwrap();
let mut cb = git2::RemoteCallbacks::new();
cb.credentials(move |url, username, allowed| {
let mut cred_helper = git2::CredentialHelper::new(url);
cred_helper.config(&git_config);
if allowed.is_ssh_key() {
// TODO: Add configuration to specify the ssh key and password(if needed)
let mut key = glib::home_dir();
key.push(".ssh");
key.push("id_rsa");

let user = username
.map(std::string::ToString::to_string)
.or_else(|| cred_helper.username.clone())
.unwrap_or_else(|| "git".to_string());
if key.exists() {
git2::Cred::ssh_key(&user, None, key.as_path(), None)
} else {
git2::Cred::ssh_key_from_agent(&user)
}
} else if allowed.is_user_pass_plaintext() {
git2::Cred::credential_helper(&git_config, url, username)
} else if allowed.is_default() {
git2::Cred::default()
} else {
Err(git2::Error::from_str("no authentication available"))
}
});
cb
}
// #[cfg(target_os = "linux")]
// fn git_callbacks() -> git2::RemoteCallbacks<'static> {
// let git_config = git2::Config::open_default().unwrap();
// let mut cb = git2::RemoteCallbacks::new();
// cb.credentials(move |url, username, allowed| {
// let mut cred_helper = git2::CredentialHelper::new(url);
// cred_helper.config(&git_config);
// if allowed.is_ssh_key() {
// // TODO: Add configuration to specify the ssh key and password(if needed)
// let mut key = glib::home_dir();
// key.push(".ssh");
// key.push("id_rsa");
//
// let user = username
// .map(std::string::ToString::to_string)
// .or_else(|| cred_helper.username.clone())
// .unwrap_or_else(|| "git".to_string());
// if key.exists() {
// git2::Cred::ssh_key(&user, None, key.as_path(), None)
// } else {
// git2::Cred::ssh_key_from_agent(&user)
// }
// } else if allowed.is_user_pass_plaintext() {
// git2::Cred::credential_helper(&git_config, url, username)
// } else if allowed.is_default() {
// git2::Cred::default()
// } else {
// Err(git2::Error::from_str("no authentication available"))
// }
// });
// cb
// }
}
8 changes: 7 additions & 1 deletion src/models/project_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ impl ProjectData {
if let Ok(mut file) = std::fs::File::open(p) {
let mut contents = String::new();
if file.read_to_string(&mut contents).is_ok() {
return serde_json::from_str(&contents).unwrap();
return match serde_json::from_str::<Uproject>(&contents) {
Ok(uproject) => uproject,
Err(e) => {
error!("Unable to parse uproject {path}: {e}");
Uproject::default()
}
};
}
}
Uproject::default()
Expand Down
3 changes: 2 additions & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ impl EpicAssetManagerWindow {
attributes.insert("type", secret_type);
let d = match expiration {
None => chrono::Utc
.timestamp(0, 0)
.timestamp_opt(0, 0)
.unwrap()
.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
Some(e) => e.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
};
Expand Down

0 comments on commit a07c459

Please sign in to comment.