mirror of
https://github.com/vrc-get/vrc-get.git
synced 2026-06-21 09:58:08 +00:00
lint: fix new lints in rust 1.88 and 1.89 beta
This commit is contained in:
parent
d02734aab8
commit
b0d32afb04
58 changed files with 305 additions and 348 deletions
|
|
@ -8,7 +8,7 @@ fn main() {
|
|||
let mut success = true;
|
||||
for arg in args {
|
||||
if arg.ends_with(".d") {
|
||||
println!("skipping .d file: {}", arg);
|
||||
println!("skipping .d file: {arg}");
|
||||
continue;
|
||||
}
|
||||
let binary = std::path::Path::new(&arg);
|
||||
|
|
@ -18,7 +18,7 @@ fn main() {
|
|||
FileKind::MachO64 => process_mach_64::<Endianness>(&binary),
|
||||
FileKind::Pe64 => process_pe_64(&binary),
|
||||
FileKind::Elf64 => process_elf_64::<Endianness>(&binary),
|
||||
unknown => panic!("unknown file type: {:?}", unknown),
|
||||
unknown => panic!("unknown file type: {unknown:?}"),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ fn main() {
|
|||
let file_name = file_name.replace("{version}", &version);
|
||||
|
||||
std::fs::metadata(format!("assets/{file_name}"))
|
||||
.unwrap_or_else(|e| panic!("{}: {}", file_name, e));
|
||||
.unwrap_or_else(|e| panic!("{file_name}: {e}"));
|
||||
|
||||
let signature = std::fs::read_to_string(format!("assets/{file_name}.sig"))
|
||||
.unwrap_or_else(|e| panic!("{}.sig: {}", file_name, e));
|
||||
.unwrap_or_else(|e| panic!("{file_name}.sig: {e}"));
|
||||
|
||||
let url = format!("{}/{}", base_url, file_name);
|
||||
let url = format!("{base_url}/{file_name}");
|
||||
platforms.insert(platform.to_string(), Platform { signature, url });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,5 +100,5 @@ fn get_commit_hash() {
|
|||
return;
|
||||
};
|
||||
|
||||
println!("cargo:rustc-env=COMMIT_HASH={}", hash_value);
|
||||
println!("cargo:rustc-env=COMMIT_HASH={hash_value}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ impl<P: Serialize + Clone> AsyncCommandContext<P> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn state<T>(&self) -> State<T>
|
||||
pub(crate) fn state<T>(&self) -> State<'_, T>
|
||||
where
|
||||
T: Send + Sync + 'static,
|
||||
{
|
||||
|
|
@ -79,7 +79,7 @@ where
|
|||
|
||||
let handle = tokio::spawn(async move {
|
||||
let context = AsyncCommandContext {
|
||||
channel: format!("{}:progress", channel),
|
||||
channel: format!("{channel}:progress"),
|
||||
window: window.clone(),
|
||||
_progress: PhantomData,
|
||||
};
|
||||
|
|
@ -88,7 +88,7 @@ where
|
|||
Err(value) => FinishedMessage::Failed(value),
|
||||
};
|
||||
|
||||
if let Err(e) = window.emit(&format!("{}:finished", channel), message) {
|
||||
if let Err(e) = window.emit(&format!("{channel}:finished"), message) {
|
||||
match e {
|
||||
tauri::Error::WebviewNotFound => {}
|
||||
_ => error!("error sending stdout: {e}"),
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ fn sync_with_real_project_background(projects: &[UserProject], app: &AppHandle)
|
|||
let mut connection = match VccDatabaseConnection::connect(io.inner()).await {
|
||||
Ok(connection) => connection,
|
||||
Err(e) => {
|
||||
error!("Error opening database: {}", e);
|
||||
error!("Error opening database: {e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
@ -231,7 +231,7 @@ fn sync_with_real_project_background(projects: &[UserProject], app: &AppHandle)
|
|||
match connection.save(io.inner()).await {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
error!("Error updating database: {}", e);
|
||||
error!("Error updating database: {e}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -487,10 +487,10 @@ where
|
|||
let new_entry = self.new_path.join(entry.relative_path());
|
||||
|
||||
if entry.is_dir() {
|
||||
if let Err(e) = tokio::fs::create_dir(&new_entry).await {
|
||||
if e.kind() != io::ErrorKind::AlreadyExists {
|
||||
return Err(e);
|
||||
}
|
||||
if let Err(e) = tokio::fs::create_dir(&new_entry).await
|
||||
&& e.kind() != io::ErrorKind::AlreadyExists
|
||||
{
|
||||
return Err(e);
|
||||
}
|
||||
|
||||
try_join_all(entry.iter().map(|x| self.process(x))).await?;
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ pub async fn environment_remove_template(
|
|||
"Template with such id not found (this is bug)",
|
||||
)),
|
||||
Some(template) => {
|
||||
info!("deleting template {id}", id = id);
|
||||
info!("deleting template {id}");
|
||||
let template = io.resolve(template.source_path.as_ref().unwrap());
|
||||
if let Err(err) = trash_delete(template.clone()).await {
|
||||
error!("failed to remove template: {err}");
|
||||
|
|
@ -400,23 +400,23 @@ pub async fn import_templates(
|
|||
template = template.display()
|
||||
);
|
||||
|
||||
if let Some(id) = &parsed.id {
|
||||
if let Some((existing_path, existing)) = installed_ids.get(id) {
|
||||
info!(
|
||||
"template {id} is duplicated with {existing_path}",
|
||||
existing_path = existing_path.display()
|
||||
);
|
||||
duplicates.push(TauriImportDuplicated {
|
||||
id: parsed.id.unwrap(),
|
||||
existing_path: existing_path.clone(),
|
||||
existing_name: existing.display_name.clone(),
|
||||
existing_update_date: existing.update_date,
|
||||
importing_name: parsed.display_name,
|
||||
importing_update_date: parsed.update_date,
|
||||
data: json,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if let Some(id) = &parsed.id
|
||||
&& let Some((existing_path, existing)) = installed_ids.get(id)
|
||||
{
|
||||
info!(
|
||||
"template {id} is duplicated with {existing_path}",
|
||||
existing_path = existing_path.display()
|
||||
);
|
||||
duplicates.push(TauriImportDuplicated {
|
||||
id: parsed.id.unwrap(),
|
||||
existing_path: existing_path.clone(),
|
||||
existing_name: existing.display_name.clone(),
|
||||
existing_update_date: existing.update_date,
|
||||
importing_name: parsed.display_name,
|
||||
importing_update_date: parsed.update_date,
|
||||
data: json,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
match save_template_file(io, &parsed.display_name, &json).await {
|
||||
|
|
|
|||
|
|
@ -535,9 +535,8 @@ async fn create_backup_zip(
|
|||
let total_files = file_tree.count_all();
|
||||
|
||||
info!(
|
||||
"Collecting files took {}, starting creating archive with {} files...",
|
||||
start.elapsed().as_secs_f64(),
|
||||
total_files
|
||||
"Collecting files took {}, starting creating archive with {total_files} files...",
|
||||
start.elapsed().as_secs_f64()
|
||||
);
|
||||
|
||||
let _ = ctx.emit(TauriCreateBackupProgress {
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ pub fn startup(app: &mut App) {
|
|||
fullscreen: bool,
|
||||
) -> tauri::Result<()> {
|
||||
info!(
|
||||
"saving window size: {}x{}, full: {}",
|
||||
size.width, size.height, fullscreen
|
||||
"saving window size: {}x{}, full: {fullscreen}",
|
||||
size.width, size.height
|
||||
);
|
||||
let config = window.state::<GuiConfigState>();
|
||||
let mut config = config.load_mut().await?;
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ enum DeepLink {
|
|||
|
||||
fn parse_deep_link(deep_link: Url) -> Option<DeepLink> {
|
||||
if deep_link.scheme() != "vcc" {
|
||||
log::error!("Invalid deep link: {}", deep_link);
|
||||
log::error!("Invalid deep link: {deep_link}");
|
||||
return None;
|
||||
}
|
||||
|
||||
if deep_link.host() != Some(Host::Domain("vpm")) {
|
||||
log::error!("Invalid deep link: {}", deep_link);
|
||||
log::error!("Invalid deep link: {deep_link}");
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ fn parse_deep_link(deep_link: Url) -> Option<DeepLink> {
|
|||
.ok()
|
||||
.filter(|x| x.scheme() == "http" || x.scheme() == "https")
|
||||
else {
|
||||
log::error!("Invalid to remove url: {}", value);
|
||||
log::error!("Invalid to remove url: {value}");
|
||||
return None;
|
||||
};
|
||||
url = Some(parsed);
|
||||
|
|
@ -56,7 +56,7 @@ fn parse_deep_link(deep_link: Url) -> Option<DeepLink> {
|
|||
headers.insert(key.to_string(), value.to_string());
|
||||
}
|
||||
_ => {
|
||||
log::error!("Unknown query parameter: {}", key);
|
||||
log::error!("Unknown query parameter: {key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ fn parse_deep_link(deep_link: Url) -> Option<DeepLink> {
|
|||
}))
|
||||
}
|
||||
_ => {
|
||||
log::error!("Unknown deep link: {}", deep_link);
|
||||
log::error!("Unknown deep link: {deep_link}");
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ pub async fn deep_link_install_vcc(_app: AppHandle) {
|
|||
}
|
||||
|
||||
if let Err(e) = impl_() {
|
||||
log::error!("Failed to install vcc deep link: {}", e);
|
||||
log::error!("Failed to install vcc deep link: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,12 +199,12 @@ Categories=Utility;
|
|||
);
|
||||
|
||||
if let Err(e) = tokio::fs::create_dir_all(&applications_dir).await {
|
||||
log::error!("Failed to create applications directory: {}", e);
|
||||
log::error!("Failed to create applications directory: {e}");
|
||||
return;
|
||||
}
|
||||
|
||||
if let Err(e) = tokio::fs::write(&desktop_file, &contents).await {
|
||||
log::error!("Failed to write desktop file: {}", e);
|
||||
log::error!("Failed to write desktop file: {e}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ Categories=Utility;
|
|||
.status()
|
||||
.await
|
||||
{
|
||||
log::error!("Failed to call update-desktop-database: {}", e);
|
||||
log::error!("Failed to call update-desktop-database: {e}");
|
||||
}
|
||||
|
||||
fn escape(s: &str) -> String {
|
||||
|
|
@ -246,7 +246,7 @@ pub async fn deep_link_uninstall_vcc(_app: AppHandle) {
|
|||
}
|
||||
|
||||
if let Err(e) = impl_() {
|
||||
log::error!("Failed to install vcc deep link: {}", e);
|
||||
log::error!("Failed to install vcc deep link: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ pub async fn deep_link_uninstall_vcc(_app: AppHandle) {
|
|||
return;
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to remove desktop file: {}", e);
|
||||
log::error!("Failed to remove desktop file: {e}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -286,7 +286,7 @@ pub async fn deep_link_uninstall_vcc(_app: AppHandle) {
|
|||
.status()
|
||||
.await
|
||||
{
|
||||
log::error!("Failed to call update-desktop-database: {}", e);
|
||||
log::error!("Failed to call update-desktop-database: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ fn start_logging_thread(receiver: mpsc::Receiver<LogChannelMessage>, io: &Defaul
|
|||
let timestamp = chrono::Utc::now()
|
||||
.format("%Y-%m-%d_%H-%M-%S.%6f")
|
||||
.to_string();
|
||||
let log_file = new_log_folder.join(format!("vrc-get-{}.log", timestamp));
|
||||
let log_file = new_log_folder.join(format!("vrc-get-{timestamp}.log"));
|
||||
|
||||
let log_file = match std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
|
|
@ -54,7 +54,7 @@ fn start_logging_thread(receiver: mpsc::Receiver<LogChannelMessage>, io: &Defaul
|
|||
Some(file)
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("error while opening log file: {}", e);
|
||||
log::error!("error while opening log file: {e}");
|
||||
None
|
||||
}
|
||||
};
|
||||
|
|
@ -115,7 +115,7 @@ fn remove_old_logs(log_folder: std::path::PathBuf) {
|
|||
let read_dir = match std::fs::read_dir(&log_folder) {
|
||||
Ok(read_dir) => read_dir,
|
||||
Err(e) => {
|
||||
log::error!("error while reading log folder: {}", e);
|
||||
log::error!("error while reading log folder: {e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
@ -123,7 +123,7 @@ fn remove_old_logs(log_folder: std::path::PathBuf) {
|
|||
let entries = match read_dir.collect::<Result<Vec<_>, _>>() {
|
||||
Ok(entries) => entries,
|
||||
Err(e) => {
|
||||
log::error!("error while reading log folder: {}", e);
|
||||
log::error!("error while reading log folder: {e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
@ -144,13 +144,13 @@ fn remove_old_logs(log_folder: std::path::PathBuf) {
|
|||
static MAX_LOGS: usize = 30;
|
||||
|
||||
for (name, _) in log_files.iter().take(MAX_LOGS) {
|
||||
log::debug!("log to keep: {}", name);
|
||||
log::debug!("log to keep: {name}");
|
||||
}
|
||||
|
||||
for (name, _) in log_files.iter().skip(MAX_LOGS) {
|
||||
match std::fs::remove_file(log_folder.join(name)) {
|
||||
Ok(()) => log::debug!("removed old log: {}", name),
|
||||
Err(e) => log::debug!("error while removing old log: {}: {}", name, e),
|
||||
Ok(()) => log::debug!("removed old log: {name}"),
|
||||
Err(e) => log::debug!("error while removing old log: {name}: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -162,13 +162,13 @@ fn logging_thread_main(
|
|||
for message in receiver {
|
||||
match message {
|
||||
LogChannelMessage::Log(entry) => {
|
||||
let message = format!("{}", entry);
|
||||
let message = format!("{entry}");
|
||||
// log to console
|
||||
eprintln!("{}", message);
|
||||
eprintln!("{message}");
|
||||
|
||||
// log to file
|
||||
if let Some(log_file) = log_file.as_mut() {
|
||||
log_err(writeln!(log_file, "{}", message));
|
||||
log_err(writeln!(log_file, "{message}"));
|
||||
}
|
||||
|
||||
// add to buffer
|
||||
|
|
@ -322,6 +322,6 @@ impl Log for Logger {
|
|||
|
||||
fn log_err<T>(result: Result<T, impl Display>) {
|
||||
if let Err(e) = result {
|
||||
eprintln!("Error while logging: {}", e);
|
||||
eprintln!("Error while logging: {e}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ mod commands;
|
|||
mod config;
|
||||
mod deep_link_support;
|
||||
mod logging;
|
||||
mod specta;
|
||||
mod templates;
|
||||
|
||||
#[cfg_attr(windows, path = "os_windows.rs")]
|
||||
|
|
@ -42,10 +41,10 @@ fn main() {
|
|||
log::info!("single instance remote procedure, {argv:?}, {cwd}");
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
if let Err(e) = window.unminimize() {
|
||||
log::error!("error while unminimize: {}", e);
|
||||
log::error!("error while unminimize: {e}");
|
||||
}
|
||||
if let Err(e) = window.set_focus() {
|
||||
log::error!("error while setting focus: {}", e);
|
||||
log::error!("error while setting focus: {e}");
|
||||
}
|
||||
}
|
||||
process_args(app, &argv);
|
||||
|
|
@ -137,6 +136,6 @@ fn process_args(app: &AppHandle, args: &[String]) {
|
|||
deep_link_support::process_files(app, vec![PathBuf::from(url)]);
|
||||
return;
|
||||
}
|
||||
log::error!("Invalid deep link: {}", url);
|
||||
log::error!("Invalid deep link: {url}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ fn os_release() -> Option<String> {
|
|||
.map(|x| x.trim_start_matches(VERSION).trim_matches('"'));
|
||||
|
||||
match (name, version) {
|
||||
(Some(name), Some(version)) => Some(format!("{} {}", name, version)),
|
||||
(Some(name), Some(version)) => Some(format!("{name} {version}")),
|
||||
(Some(name), None) => Some(name.into()),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -103,8 +103,7 @@ pub fn open_that(path: impl AsRef<OsStr>) -> io::Result<()> {
|
|||
|
||||
if !status.success() {
|
||||
return Err(io::Error::other(format!(
|
||||
"Launcher xdg-open failed with {:?}",
|
||||
status
|
||||
"Launcher xdg-open failed with {status:?}",
|
||||
)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,7 @@ pub(crate) async fn start_command(
|
|||
|
||||
if !status.success() {
|
||||
Err(std::io::Error::other(format!(
|
||||
"cmd.exe /E:ON /V:OFF /d /c start /d failed with status: {}",
|
||||
status
|
||||
"cmd.exe /E:ON /V:OFF /d /c start /d failed with status: {status}",
|
||||
)))
|
||||
} else {
|
||||
Ok(())
|
||||
|
|
@ -222,7 +221,7 @@ pub fn os_info() -> &'static str {
|
|||
let ex_version = if ex_version.is_empty() {
|
||||
"".to_string()
|
||||
} else {
|
||||
format!(" ({})", ex_version)
|
||||
format!(" ({ex_version})")
|
||||
};
|
||||
|
||||
format!(
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
use indexmap::IndexMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Eq, PartialEq, Clone)]
|
||||
#[serde(transparent)]
|
||||
pub struct IndexMapV2<K: std::hash::Hash + Eq, V>(pub IndexMap<K, V>);
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait StringLike: std::hash::Hash + Eq {}
|
||||
|
||||
impl StringLike for Box<str> {}
|
||||
impl StringLike for String {}
|
||||
|
|
@ -133,7 +133,7 @@ impl ChangesVersionRef<'_> {
|
|||
}
|
||||
|
||||
/// Panics if the data has already been taken.
|
||||
pub fn take_changes(&mut self) -> PendingProjectChanges {
|
||||
pub fn take_changes(&mut self) -> PendingProjectChanges<'_> {
|
||||
let yoke = self.data.take().unwrap();
|
||||
// SAFETY: We have clone of backing_cart in self, so yokeable will live while self lives.
|
||||
unsafe { yoke.replace_cart(|_| ()) }.into_yokeable().changes
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ async fn load_async(io: &DefaultEnvironmentIo) -> io::Result<GuiConfigStateInner
|
|||
async fn backup_old_config(path: &Path) -> io::Result<()> {
|
||||
let mut i = 0;
|
||||
loop {
|
||||
let backup_path = path.with_extension(format!("json.bak.{}", i));
|
||||
let backup_path = path.with_extension(format!("json.bak.{i}"));
|
||||
match tokio::fs::rename(path, &backup_path).await {
|
||||
Err(e) if e.kind() == io::ErrorKind::AlreadyExists => {
|
||||
i += 1;
|
||||
|
|
@ -134,14 +134,11 @@ async fn load_async(io: &DefaultEnvironmentIo) -> io::Result<GuiConfigStateInner
|
|||
let config = match load_fs(&path).await {
|
||||
Ok(loaded) => loaded,
|
||||
Err(e) => {
|
||||
log::error!(
|
||||
"Failed to load gui-config.json, using default config: {}",
|
||||
e
|
||||
);
|
||||
log::error!("Failed to load gui-config.json, using default config: {e}");
|
||||
|
||||
// backup old config if possible
|
||||
if let Err(e) = backup_old_config(&path).await {
|
||||
log::error!("Failed to backup old config: {}", e);
|
||||
log::error!("Failed to backup old config: {e}");
|
||||
}
|
||||
|
||||
GuiConfig::default()
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ impl PackagesState {
|
|||
settings: &Settings,
|
||||
io: &DefaultEnvironmentIo,
|
||||
http: &reqwest::Client,
|
||||
) -> io::Result<PackagesStateRef> {
|
||||
) -> io::Result<PackagesStateRef<'_>> {
|
||||
self.load_impl(settings, io, http, None, true).await
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ impl PackagesState {
|
|||
http: &reqwest::Client,
|
||||
app_handle: Option<AppHandle>,
|
||||
force: bool,
|
||||
) -> io::Result<PackagesStateRef> {
|
||||
) -> io::Result<PackagesStateRef<'_>> {
|
||||
// We won't allow multiple threads to load the data at the same time.
|
||||
let guard = self.load_lock.lock().await;
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ impl PackagesStateRef<'_> {
|
|||
self.arc.data.backing_cart()
|
||||
}
|
||||
|
||||
pub fn packages(&self) -> impl Iterator<Item = &PackageInfo> {
|
||||
pub fn packages(&self) -> impl Iterator<Item = &PackageInfo<'_>> {
|
||||
self.arc.data.get().packages.iter()
|
||||
}
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ impl PackagesVersionRef<'_> {
|
|||
self.arc.data.backing_cart().clone()
|
||||
}
|
||||
|
||||
pub fn packages(&self) -> &[PackageInfo] {
|
||||
pub fn packages(&self) -> &[PackageInfo<'_>] {
|
||||
&self.arc.data.get().packages
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ impl SettingsState {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn load(&self, io: &DefaultEnvironmentIo) -> io::Result<SettingsRef> {
|
||||
pub async fn load(&self, io: &DefaultEnvironmentIo) -> io::Result<SettingsRef<'_>> {
|
||||
// If the data is new enough, we can use it.
|
||||
let inner = self.inner.load_full();
|
||||
if let Some(inner) = inner.filter(|x| x.is_new()) {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ pub async fn load_vcc_templates(io: &DefaultEnvironmentIo) -> Vec<ProjectTemplat
|
|||
}
|
||||
Ok(p) => templates.push(ProjectTemplateInfo {
|
||||
display_name: name.clone(),
|
||||
id: format!("{}{}", VCC_TEMPLATE_PREFIX, name),
|
||||
id: format!("{VCC_TEMPLATE_PREFIX}{name}"),
|
||||
unity_versions: vec![p.unity_version()],
|
||||
update_date: None,
|
||||
alcom_template: None,
|
||||
|
|
@ -225,8 +225,7 @@ pub async fn load_resolve_alcom_templates(
|
|||
|
||||
pub fn new_user_template_id() -> String {
|
||||
format!(
|
||||
"{}{}",
|
||||
UNNAMED_TEMPLATE_PREFIX,
|
||||
"{UNNAMED_TEMPLATE_PREFIX}{}",
|
||||
uuid::Uuid::new_v4().as_simple()
|
||||
)
|
||||
}
|
||||
|
|
@ -749,11 +748,9 @@ async fn update_project_name_and_guid(path: &Path, project_name: &str) -> io::Re
|
|||
.last()
|
||||
.map(|x| x.is_ascii_whitespace())
|
||||
.unwrap_or(true);
|
||||
if before_ws {
|
||||
if let Some(eol) = buffer[pos..].find('\n') {
|
||||
let eol = eol + pos;
|
||||
buffer.replace_range((pos + finder.len())..eol, value);
|
||||
}
|
||||
if before_ws && let Some(eol) = buffer[pos..].find('\n') {
|
||||
let eol = eol + pos;
|
||||
buffer.replace_range((pos + finder.len())..eol, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -763,7 +760,7 @@ async fn update_project_name_and_guid(path: &Path, project_name: &str) -> io::Re
|
|||
.replace('"', "\\\"")
|
||||
.replace('\n', "\\n")
|
||||
.replace('\r', "\\r");
|
||||
format!("\"{}\"", s)
|
||||
format!("\"{s}\"")
|
||||
}
|
||||
|
||||
set_value(
|
||||
|
|
|
|||
|
|
@ -119,13 +119,13 @@ pub fn parse_alcom_template(alcom_template: &[u8]) -> serde_json::Result<AlcomTe
|
|||
let template = serde_json::from_slice::<AlcomTemplateContent>(json)?;
|
||||
|
||||
// few validations
|
||||
if let Some(id) = &template.id {
|
||||
if !is_valid_id(&id.0) {
|
||||
return Err(serde_json::Error::invalid_value(
|
||||
Unexpected::Str(&id.0),
|
||||
&"a valid alcom template id",
|
||||
));
|
||||
}
|
||||
if let Some(id) = &template.id
|
||||
&& !is_valid_id(&id.0)
|
||||
{
|
||||
return Err(serde_json::Error::invalid_value(
|
||||
Unexpected::Str(&id.0),
|
||||
&"a valid alcom template id",
|
||||
));
|
||||
}
|
||||
|
||||
if !is_valid_base_id(&template.base.0) {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ pub(crate) fn find_existing_parent_dir(path: &Path) -> Option<&Path> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn find_existing_parent_dir_or_home(path: &Path) -> Cow<Path> {
|
||||
pub(crate) fn find_existing_parent_dir_or_home(path: &Path) -> Cow<'_, Path> {
|
||||
find_existing_parent_dir(path)
|
||||
.map(Cow::Borrowed)
|
||||
.unwrap_or_else(|| Cow::Owned(home_dir()))
|
||||
|
|
@ -171,14 +171,14 @@ impl FileSystemTree {
|
|||
&self.absolute_path
|
||||
}
|
||||
|
||||
pub fn recursive(&self) -> FileSystemTreeRecursive {
|
||||
pub fn recursive(&self) -> FileSystemTreeRecursive<'_> {
|
||||
FileSystemTreeRecursive {
|
||||
stack: vec![(self, 0)],
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn iter(&self) -> FileSystemTreeIter {
|
||||
pub fn iter(&self) -> FileSystemTreeIter<'_> {
|
||||
FileSystemTreeIter {
|
||||
back: self.children.iter(),
|
||||
}
|
||||
|
|
@ -458,7 +458,7 @@ impl<R: AsyncRead + Unpin> TarArchive<R> {
|
|||
Self { reader, to_skip: 0 }
|
||||
}
|
||||
|
||||
pub async fn next_entry(&mut self) -> io::Result<Option<TarEntry<R>>> {
|
||||
pub async fn next_entry(&mut self) -> io::Result<Option<TarEntry<'_, R>>> {
|
||||
const BLOCK_SIZE: u64 = 512;
|
||||
let mut header = Header::new_old();
|
||||
// skip bytes
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ pub async fn add_remote_repo(
|
|||
|
||||
io.create_dir_all(REPO_CACHE_FOLDER.as_ref()).await?;
|
||||
let file_name = write_new_repo(&local_cache, io).await?;
|
||||
let repo_path = io.resolve(format!("{}/{}", REPO_CACHE_FOLDER, file_name).as_ref());
|
||||
let repo_path = io.resolve(format!("{REPO_CACHE_FOLDER}/{file_name}").as_ref());
|
||||
|
||||
assert!(
|
||||
settings.add_remote_repo(&url, name, headers, local_cache.repo(), &repo_path),
|
||||
|
|
@ -95,17 +95,15 @@ pub async fn cleanup_repos_folder(
|
|||
let repos_base = io.resolve(REPO_CACHE_FOLDER.as_ref());
|
||||
|
||||
for x in settings.get_user_repos() {
|
||||
if let Ok(relative) = x.local_path().strip_prefix(&repos_base) {
|
||||
if let Some(file_name) = relative.file_name() {
|
||||
if relative
|
||||
.parent()
|
||||
.map(|x| x.as_os_str().is_empty())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
// the file must be in direct child of
|
||||
uesr_repo_file_names.insert(file_name.to_owned());
|
||||
}
|
||||
}
|
||||
if let Ok(relative) = x.local_path().strip_prefix(&repos_base)
|
||||
&& let Some(file_name) = relative.file_name()
|
||||
&& relative
|
||||
.parent()
|
||||
.map(|x| x.as_os_str().is_empty())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
// the file must be in direct child of
|
||||
uesr_repo_file_names.insert(file_name.to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +143,7 @@ async fn write_new_repo(
|
|||
let id_names = local_cache
|
||||
.id()
|
||||
.filter(|id| is_id_name_for_file(id))
|
||||
.map(|id| format!("{}.json", id))
|
||||
.map(|id| format!("{id}.json"))
|
||||
.into_iter();
|
||||
|
||||
// finally generate with uuid v4.
|
||||
|
|
@ -154,7 +152,7 @@ async fn write_new_repo(
|
|||
|
||||
for file_name in id_names.chain(guid_names) {
|
||||
match io
|
||||
.create_new(format!("{}/{}", REPO_CACHE_FOLDER, file_name).as_ref())
|
||||
.create_new(format!("{REPO_CACHE_FOLDER}/{file_name}").as_ref())
|
||||
.await
|
||||
{
|
||||
Ok(mut file) => {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ impl PackageCollection {
|
|||
&self,
|
||||
version_selector: VersionSelector,
|
||||
filter: impl Fn(&PackageManifest) -> bool,
|
||||
) -> Vec<PackageInfo> {
|
||||
) -> Vec<PackageInfo<'_>> {
|
||||
self.get_all_packages()
|
||||
.filter(|x| version_selector.satisfies(x.package_json()))
|
||||
.into_group_map_by(|x| x.name())
|
||||
|
|
@ -101,7 +101,7 @@ impl crate::PackageCollection for PackageCollection {
|
|||
fn get_curated_packages(
|
||||
&self,
|
||||
version_selector: VersionSelector,
|
||||
) -> impl Iterator<Item = PackageInfo> {
|
||||
) -> impl Iterator<Item = PackageInfo<'_>> {
|
||||
self.repositories
|
||||
.find_by_id("com.vrchat.repos.curated")
|
||||
.map(move |repo| {
|
||||
|
|
@ -114,7 +114,7 @@ impl crate::PackageCollection for PackageCollection {
|
|||
.flatten()
|
||||
}
|
||||
|
||||
fn get_all_packages(&self) -> impl Iterator<Item = PackageInfo> {
|
||||
fn get_all_packages(&self) -> impl Iterator<Item = PackageInfo<'_>> {
|
||||
let remote = self.repositories.iter().flat_map(|repo| {
|
||||
repo.repo
|
||||
.get_packages()
|
||||
|
|
@ -129,7 +129,7 @@ impl crate::PackageCollection for PackageCollection {
|
|||
remote.chain(local)
|
||||
}
|
||||
|
||||
fn find_packages(&self, package: &str) -> impl Iterator<Item = PackageInfo> {
|
||||
fn find_packages(&self, package: &str) -> impl Iterator<Item = PackageInfo<'_>> {
|
||||
let remote = self.repositories.iter().flat_map(|repo| {
|
||||
repo.repo
|
||||
.get_package(package)
|
||||
|
|
@ -149,7 +149,7 @@ impl crate::PackageCollection for PackageCollection {
|
|||
&self,
|
||||
package: &str,
|
||||
package_selector: VersionSelector,
|
||||
) -> Option<PackageInfo> {
|
||||
) -> Option<PackageInfo<'_>> {
|
||||
let remote = self.repositories.iter().flat_map(|repo| {
|
||||
repo.repo
|
||||
.get_package(package)
|
||||
|
|
|
|||
|
|
@ -53,10 +53,9 @@ impl<T: HttpClient> crate::PackageInstaller for PackageInstaller<'_, T> {
|
|||
if let Err(e) = crate::utils::extract_zip(zip_file, io, &dest_folder).await {
|
||||
// if an error occurs, try to remove the dest folder
|
||||
log::debug!(
|
||||
"Error occurred while extracting zip file for {}@{}: {}",
|
||||
"Error occurred while extracting zip file for {}@{}: {e}",
|
||||
package.name(),
|
||||
package.version(),
|
||||
e
|
||||
);
|
||||
let _ = io.remove_dir_all(&dest_folder).await;
|
||||
return Err(e);
|
||||
|
|
@ -85,8 +84,7 @@ async fn get_package<T: HttpClient>(
|
|||
) -> io::Result<TokioFile> {
|
||||
let zip_file_name = format!("vrc-get-{}-{}.zip", &package.name(), package.version());
|
||||
let zip_path = PathBuf::from(format!(
|
||||
"{}/{}/{}",
|
||||
REPO_CACHE_FOLDER,
|
||||
"{REPO_CACHE_FOLDER}/{}/{}",
|
||||
package.name(),
|
||||
&zip_file_name
|
||||
));
|
||||
|
|
@ -132,15 +130,14 @@ async fn get_package<T: HttpClient>(
|
|||
if let Some(repo_hash) = package
|
||||
.zip_sha_256()
|
||||
.and_then(|x| <[u8; 256 / 8] as FromHex>::from_hex(x).ok())
|
||||
&& repo_hash != zip_hash
|
||||
{
|
||||
if repo_hash != zip_hash {
|
||||
error!(
|
||||
"Package hash mismatched! This will be hard error in the future!: {} v{}",
|
||||
package.name(),
|
||||
package.version()
|
||||
);
|
||||
//return None;
|
||||
}
|
||||
error!(
|
||||
"Package hash mismatched! This will be hard error in the future!: {} v{}",
|
||||
package.name(),
|
||||
package.version()
|
||||
);
|
||||
//return None;
|
||||
}
|
||||
|
||||
Ok(zip_file)
|
||||
|
|
@ -175,10 +172,10 @@ async fn try_load_package_cache(
|
|||
let hex: [u8; 256 / 8] = FromHex::from_hex(buf).ok()?;
|
||||
|
||||
// if stored sha doesn't match sha in repo: current cache is invalid
|
||||
if let Some(repo_hash) = sha256.and_then(|x| <[u8; 256 / 8] as FromHex>::from_hex(x).ok()) {
|
||||
if repo_hash != hex {
|
||||
return None;
|
||||
}
|
||||
if let Some(repo_hash) = sha256.and_then(|x| <[u8; 256 / 8] as FromHex>::from_hex(x).ok())
|
||||
&& repo_hash != hex
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut hasher = Sha256AsyncWrite::new(io::sink());
|
||||
|
|
@ -222,12 +219,12 @@ async fn download_package_zip(
|
|||
// file not found: err
|
||||
let cache_file = io.create(zip_path).await?;
|
||||
|
||||
debug!("Download started for {}", url);
|
||||
debug!("Download started for {url}");
|
||||
let mut response = pin!(http.get(url, headers).await?);
|
||||
|
||||
let mut writer = Sha256AsyncWrite::new(cache_file);
|
||||
io::copy(&mut response, &mut writer).await?;
|
||||
debug!("finished downloading {}", url);
|
||||
debug!("finished downloading {url}");
|
||||
|
||||
let (mut cache_file, hash) = writer.finalize();
|
||||
let hash: [u8; 256 / 8] = hash.into();
|
||||
|
|
@ -238,7 +235,7 @@ async fn download_package_zip(
|
|||
// write sha file
|
||||
io.write(
|
||||
sha_path,
|
||||
format!("{} {}\n", hex::encode(&hash[..]), zip_file_name).as_bytes(),
|
||||
format!("{} {zip_file_name}\n", hex::encode(&hash[..])).as_bytes(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ impl VccDatabaseConnection {
|
|||
if Path::new(x.as_ref()).is_absolute() {
|
||||
true
|
||||
} else {
|
||||
error!("Skipping relative path: {}", x);
|
||||
error!("Skipping relative path: {x}");
|
||||
false
|
||||
}
|
||||
})
|
||||
|
|
@ -161,14 +161,14 @@ impl VccDatabaseConnection {
|
|||
Ok(Some(project)) => Some(RealProjectInformation::Valid(project)),
|
||||
Ok(None) => {
|
||||
if !skip_not_found {
|
||||
error!("Project {} not found", path);
|
||||
error!("Project {path} not found");
|
||||
}
|
||||
Some(RealProjectInformation::Invalid(
|
||||
InvalidRealProjectInformation::new(path.into()),
|
||||
))
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Error updating project information: {}", err);
|
||||
error!("Error updating project information: {err}");
|
||||
Some(RealProjectInformation::Invalid(
|
||||
InvalidRealProjectInformation::new(path.into()),
|
||||
))
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl Repository {
|
|||
}
|
||||
}
|
||||
|
||||
fn remote_download_info(&self) -> Option<RemoteDownloadInfo> {
|
||||
fn remote_download_info(&self) -> Option<RemoteDownloadInfo<'_>> {
|
||||
match self {
|
||||
Repository::Loaded(repo) => repo.url().map(|url| RemoteDownloadInfo {
|
||||
url,
|
||||
|
|
@ -175,14 +175,14 @@ impl RepoHolder {
|
|||
Ok(Some(v)) => (src.cache_path().into(), Repository::Loaded(v)),
|
||||
Ok(None) => if_not_exists(src),
|
||||
Err(e) => {
|
||||
error!("loading repo '{}': {}", src.cache_path().display(), e);
|
||||
error!("loading repo '{}': {e}", src.cache_path().display());
|
||||
if_not_exists(src)
|
||||
}
|
||||
}
|
||||
}))
|
||||
.await;
|
||||
let duration = std::time::Instant::now() - start;
|
||||
log::debug!("loading repo cache took {:?}", duration);
|
||||
log::debug!("loading repo cache took {duration:?}");
|
||||
|
||||
for (path, repo) in repos.into_iter() {
|
||||
self.cached_repos_new.insert(path, repo);
|
||||
|
|
@ -258,7 +258,7 @@ impl RepoHolder {
|
|||
}
|
||||
|
||||
if let Err(e) = save_repository(io, path, new_repository).await {
|
||||
error!("writing local repo cache '{}': {}", path.display(), e);
|
||||
error!("writing local repo cache '{}': {e}", path.display());
|
||||
}
|
||||
}
|
||||
Ok(None) => {
|
||||
|
|
@ -297,7 +297,7 @@ impl RepoHolder {
|
|||
fn log_error(result: Vec<Result<bool, (Url, io::Error)>>) {
|
||||
for result in result {
|
||||
if let Some((url, error)) = result.err() {
|
||||
error!("fetching remote repo '{}': {}", url, error);
|
||||
error!("fetching remote repo '{url}': {error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,11 +303,11 @@ impl Settings {
|
|||
query_builder.append_pair("url", url.as_str());
|
||||
|
||||
for (header_name, value) in setting.headers() {
|
||||
query_builder.append_pair("headers[]", &format!("{}:{}", header_name, value));
|
||||
query_builder.append_pair("headers[]", &format!("{header_name}:{value}"));
|
||||
}
|
||||
drop(query_builder);
|
||||
|
||||
writeln!(builder, "{}", add_url).unwrap();
|
||||
writeln!(builder, "{add_url}").unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ impl UserPackageCollection {
|
|||
log::warn!("package.json not found in {}", folder.display());
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Failed to load package.json in {}: {}", folder.display(), e);
|
||||
log::warn!("Failed to load package.json in {}: {e}", folder.display());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,14 +115,14 @@ impl VccDatabaseConnection {
|
|||
let path_path = Path::new(path);
|
||||
if !io.is_file(path_path).await {
|
||||
// if the unity editor not found, remove it from the db
|
||||
info!("Removed nonexistent Unity: {}", path);
|
||||
info!("Removed nonexistent Unity: {path}");
|
||||
delete.push(in_db["_id"].clone());
|
||||
continue;
|
||||
}
|
||||
|
||||
if registered.contains(path_path) {
|
||||
// if the unity editor is already installed, remove it from the db
|
||||
info!("Removed duplicate Unity: {}", path);
|
||||
info!("Removed duplicate Unity: {path}");
|
||||
delete.push(in_db["_id"].clone());
|
||||
continue;
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ impl VccDatabaseConnection {
|
|||
continue;
|
||||
};
|
||||
if !registered.contains(Path::new(path)) {
|
||||
info!("Adding Unity from Unity Hub: {}", path);
|
||||
info!("Adding Unity from Unity Hub: {path}");
|
||||
Self::add_unity_installation_internal(&mut self.db, path, version, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -231,7 +231,7 @@ fn default_unity_hub_path() -> &'static [&'static str] {
|
|||
lazy_static::lazy_static! {
|
||||
static ref USER_INSTALLATION: String = {
|
||||
let home = std::env::var("HOME").expect("HOME not set");
|
||||
format!("{}/Applications/Unity Hub.AppImage", home)
|
||||
format!("{home}/Applications/Unity Hub.AppImage")
|
||||
};
|
||||
static ref FLATPAK_USER_INSTALLATION: String = {
|
||||
let data_home = std::env::var("XDG_DATA_HOME")
|
||||
|
|
|
|||
|
|
@ -95,11 +95,11 @@ impl VpmSettings {
|
|||
let mut changed = false;
|
||||
|
||||
for repo in &mut json.user_repos {
|
||||
if let Some(cache) = collection.repositories.get_by_path(repo.local_path()) {
|
||||
if cache.repo.id() != repo.id() {
|
||||
repo.id = cache.repo.id().map(|x| x.into());
|
||||
changed = true;
|
||||
}
|
||||
if let Some(cache) = collection.repositories.get_by_path(repo.local_path())
|
||||
&& cache.repo.id() != repo.id()
|
||||
{
|
||||
repo.id = cache.repo.id().map(|x| x.into());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,13 +42,13 @@ impl DefaultEnvironmentIo {
|
|||
#[cfg(not(windows))]
|
||||
fn get_local_config_folder() -> PathBuf {
|
||||
if let Some(data_home) = std::env::var_os("XDG_DATA_HOME") {
|
||||
debug!("XDG_DATA_HOME found {:?}", data_home);
|
||||
debug!("XDG_DATA_HOME found {data_home:?}");
|
||||
return data_home.into();
|
||||
}
|
||||
|
||||
// fallback: use HOME
|
||||
if let Some(home_folder) = std::env::var_os("HOME") {
|
||||
debug!("HOME found {:?}", home_folder);
|
||||
debug!("HOME found {home_folder:?}");
|
||||
let mut path = PathBuf::from(home_folder);
|
||||
path.push(".local/share");
|
||||
return path;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ fn parse_add_repo_link(vcc_url: Url) -> Option<RepositoryInfo> {
|
|||
);
|
||||
}
|
||||
_ => {
|
||||
log::error!("Unknown query parameter: {}", key);
|
||||
log::error!("Unknown query parameter: {key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ impl RemoteRepository {
|
|||
headers: &IndexMap<Box<str>, Box<str>>,
|
||||
current_etag: Option<&str>,
|
||||
) -> io::Result<Option<(RemoteRepository, Option<Box<str>>)>> {
|
||||
let Some((mut stream, etag)) = client.get_with_etag(url, headers, current_etag).await?
|
||||
else {
|
||||
let Some((stream, etag)) = client.get_with_etag(url, headers, current_etag).await? else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
|
|
@ -315,10 +314,9 @@ impl<'de> DeserializeSeed<'de> for ErrorProofManifest<'_> {
|
|||
Ok(manifest) => Ok(Some(manifest)),
|
||||
Err(err) => {
|
||||
log::warn!(
|
||||
"Error deserializing package manifest for {}@{}: {}",
|
||||
"Error deserializing package manifest for {}@{}: {err}",
|
||||
self.0,
|
||||
self.1,
|
||||
err
|
||||
);
|
||||
Ok(None)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ pub mod setting {
|
|||
&self.headers
|
||||
}
|
||||
|
||||
pub(crate) fn to_source(&self) -> RepoSource {
|
||||
pub(crate) fn to_source(&self) -> RepoSource<'_> {
|
||||
RepoSource::new(&self.local_path, &self.headers, self.url.as_ref())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,22 +15,22 @@ pub trait PackageCollection {
|
|||
fn get_curated_packages(
|
||||
&self,
|
||||
_version_selector: VersionSelector,
|
||||
) -> impl Iterator<Item = PackageInfo> {
|
||||
) -> impl Iterator<Item = PackageInfo<'_>> {
|
||||
[].into_iter()
|
||||
}
|
||||
|
||||
/// get all packages in the collection
|
||||
fn get_all_packages(&self) -> impl Iterator<Item = PackageInfo>;
|
||||
fn get_all_packages(&self) -> impl Iterator<Item = PackageInfo<'_>>;
|
||||
|
||||
/// get all package versions of the specified package
|
||||
fn find_packages(&self, package: &str) -> impl Iterator<Item = PackageInfo>;
|
||||
fn find_packages(&self, package: &str) -> impl Iterator<Item = PackageInfo<'_>>;
|
||||
|
||||
/// get specified version of specified package
|
||||
fn find_package_by_name(
|
||||
&self,
|
||||
package: &str,
|
||||
package_selector: VersionSelector,
|
||||
) -> Option<PackageInfo>;
|
||||
) -> Option<PackageInfo<'_>>;
|
||||
}
|
||||
|
||||
/// The trait for installing package
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub use os::load_unity_version;
|
|||
///
|
||||
/// On macOS, this function expects Path to .app file and returns binary file.
|
||||
/// On other platforms, does nothing
|
||||
pub fn get_executable_path(path: &Path) -> Cow<Path> {
|
||||
pub fn get_executable_path(path: &Path) -> Cow<'_, Path> {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
Cow::Borrowed(path)
|
||||
|
|
|
|||
|
|
@ -62,10 +62,10 @@ async fn get_custom_install_location(local_settings: &LocalSettings) -> Option<P
|
|||
return Some(PathBuf::from(user_setting));
|
||||
}
|
||||
let global_setting = &local_settings.machine_wide_install_location;
|
||||
if let Some(global_setting) = global_setting {
|
||||
if !global_setting.as_os_str().is_empty() {
|
||||
return Some(global_setting.clone());
|
||||
}
|
||||
if let Some(global_setting) = global_setting
|
||||
&& !global_setting.as_os_str().is_empty()
|
||||
{
|
||||
return Some(global_setting.clone());
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,12 +77,11 @@ impl UnityProject {
|
|||
}
|
||||
let read = Self::try_read_unlocked_package(&io, dir_entry).await;
|
||||
let mut is_installed = false;
|
||||
if let Some(parsed) = &read.1 {
|
||||
if parsed.name() == read.0.as_ref()
|
||||
&& manifest.get_locked(parsed.name()).is_some()
|
||||
{
|
||||
is_installed = true;
|
||||
}
|
||||
if let Some(parsed) = &read.1
|
||||
&& parsed.name() == read.0.as_ref()
|
||||
&& manifest.get_locked(parsed.name()).is_some()
|
||||
{
|
||||
is_installed = true;
|
||||
}
|
||||
if is_installed {
|
||||
installed_packages.insert(read.0, read.1.unwrap());
|
||||
|
|
@ -206,7 +205,7 @@ impl UnityProject {
|
|||
|
||||
// accessors
|
||||
impl UnityProject {
|
||||
pub fn locked_packages(&self) -> impl Iterator<Item = LockedDependencyInfo> {
|
||||
pub fn locked_packages(&self) -> impl Iterator<Item = LockedDependencyInfo<'_>> {
|
||||
self.manifest.all_locked()
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +213,7 @@ impl UnityProject {
|
|||
self.manifest.dependencies().map(|(name, _)| name)
|
||||
}
|
||||
|
||||
pub fn get_locked(&self, name: &str) -> Option<LockedDependencyInfo> {
|
||||
pub fn get_locked(&self, name: &str) -> Option<LockedDependencyInfo<'_>> {
|
||||
self.manifest.get_locked(name)
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +221,7 @@ impl UnityProject {
|
|||
self.manifest.get_locked(name).is_some()
|
||||
}
|
||||
|
||||
pub fn all_packages(&self) -> impl Iterator<Item = LockedDependencyInfo> {
|
||||
pub fn all_packages(&self) -> impl Iterator<Item = LockedDependencyInfo<'_>> {
|
||||
let dependencies_locked = self.manifest.all_locked();
|
||||
|
||||
let dependencies_unlocked = self
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ impl UnityProject {
|
|||
}
|
||||
|
||||
for (package, conflicts_with) in result.conflicts {
|
||||
debug!("package {} conflicts with {:?}", package, conflicts_with);
|
||||
debug!("package {package} conflicts with {conflicts_with:?}");
|
||||
changes.conflict_multiple(package, conflicts_with);
|
||||
}
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ impl UnityProject {
|
|||
.into_iter()
|
||||
.filter(|name| self.is_locked(name))
|
||||
{
|
||||
debug!("removing legacy package {}", name);
|
||||
debug!("removing legacy package {name}");
|
||||
changes.remove(name, RemoveReason::Legacy);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,14 +224,14 @@ async fn find_legacy_assets_by_guid<'a>(
|
|||
pin!(walk_dir_relative(io, [PathBuf::from("Assets")]).filter_map(|(x, _)| get_guid(io, x)));
|
||||
|
||||
while let Some((guid, is_file_actual, relative)) = stream.next().await {
|
||||
if let Some(&(package_name, is_file)) = find_guids.get(&guid) {
|
||||
if is_file_actual == is_file {
|
||||
find_guids.remove(&guid);
|
||||
if is_file {
|
||||
found_files.insert(relative.into_boxed_path(), package_name);
|
||||
} else {
|
||||
found_folders.insert(relative.into_boxed_path(), package_name);
|
||||
}
|
||||
if let Some(&(package_name, is_file)) = find_guids.get(&guid)
|
||||
&& is_file_actual == is_file
|
||||
{
|
||||
find_guids.remove(&guid);
|
||||
if is_file {
|
||||
found_files.insert(relative.into_boxed_path(), package_name);
|
||||
} else {
|
||||
found_folders.insert(relative.into_boxed_path(), package_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ impl std::fmt::Display for MigrateUnity2022Error {
|
|||
match self {
|
||||
MigrateUnity2022Error::UnityVersionMismatch => write!(f, "Unity version is not 2019.x"),
|
||||
MigrateUnity2022Error::VpmPackageNotFound(name) => {
|
||||
write!(f, "VPM package {} not found", name)
|
||||
write!(f, "VPM package {name} not found")
|
||||
}
|
||||
MigrateUnity2022Error::AddPackageErr(err) => write!(f, "{}", err),
|
||||
MigrateUnity2022Error::Io(err) => write!(f, "{}", err),
|
||||
MigrateUnity2022Error::AddPackageErr(err) => write!(f, "{err}"),
|
||||
MigrateUnity2022Error::Io(err) => write!(f, "{err}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@ impl std::fmt::Display for MigrateVpmError {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
MigrateVpmError::ProjectTypeMismatch(either) => {
|
||||
write!(f, "Project type is {:?}", either)
|
||||
write!(f, "Project type is {either:?}")
|
||||
}
|
||||
MigrateVpmError::UnityVersionMismatch => write!(f, "Unity version is not 2019.x"),
|
||||
MigrateVpmError::VpmPackageNotFound(name) => {
|
||||
write!(f, "VPM package {} not found", name)
|
||||
write!(f, "VPM package {name} not found")
|
||||
}
|
||||
MigrateVpmError::AddPackageErr(err) => write!(f, "{}", err),
|
||||
MigrateVpmError::Io(err) => write!(f, "{}", err),
|
||||
MigrateVpmError::AddPackageErr(err) => write!(f, "{err}"),
|
||||
MigrateVpmError::Io(err) => write!(f, "{err}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -114,8 +114,7 @@ async fn migrate_vpm(
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
debug!(
|
||||
"Trying to add the following curated packages to find legacy curated packages with legacyAssets: {:?}",
|
||||
curated_packages
|
||||
"Trying to add the following curated packages to find legacy curated packages with legacyAssets: {curated_packages:?}"
|
||||
);
|
||||
|
||||
let packages = project
|
||||
|
|
|
|||
|
|
@ -314,13 +314,13 @@ where
|
|||
}
|
||||
} else {
|
||||
// if already installed version is good, no need to reinstall
|
||||
if let Some(version) = &entry.current {
|
||||
if range.match_pre(version, allow_prerelease) {
|
||||
log::debug!(
|
||||
"processing package {name}: dependency {name} version {range}: existing matches"
|
||||
);
|
||||
install = false;
|
||||
}
|
||||
if let Some(version) = &entry.current
|
||||
&& range.match_pre(version, allow_prerelease)
|
||||
{
|
||||
log::debug!(
|
||||
"processing package {name}: dependency {name} version {range}: existing matches"
|
||||
);
|
||||
install = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -332,38 +332,39 @@ impl<'env> ResolutionContext<'env, '_> {
|
|||
pub(crate) fn build_result(self) -> PackageResolutionResult<'env> {
|
||||
let mut conflicts = HashMap::<Box<str>, Vec<Box<str>>>::new();
|
||||
for (&name, info) in &self.dependencies {
|
||||
if !info.is_legacy() && info.touched {
|
||||
if let Some(version) = &info.current {
|
||||
let conflicts_with_this = info
|
||||
.requirements
|
||||
.iter()
|
||||
.filter(|&(&source, _)| {
|
||||
self.dependencies
|
||||
.get(source)
|
||||
.map(|x| !x.is_legacy())
|
||||
.unwrap_or_default()
|
||||
})
|
||||
.filter(|(_, range)| {
|
||||
!range.match_pre(
|
||||
version,
|
||||
PrereleaseAcceptance::allow_or_minimum(
|
||||
info.allow_pre || self.allow_prerelease,
|
||||
),
|
||||
)
|
||||
})
|
||||
.map(|(source, _)| *source)
|
||||
.collect::<Vec<_>>();
|
||||
if !info.is_legacy()
|
||||
&& info.touched
|
||||
&& let Some(version) = &info.current
|
||||
{
|
||||
let conflicts_with_this = info
|
||||
.requirements
|
||||
.iter()
|
||||
.filter(|&(&source, _)| {
|
||||
self.dependencies
|
||||
.get(source)
|
||||
.map(|x| !x.is_legacy())
|
||||
.unwrap_or_default()
|
||||
})
|
||||
.filter(|(_, range)| {
|
||||
!range.match_pre(
|
||||
version,
|
||||
PrereleaseAcceptance::allow_or_minimum(
|
||||
info.allow_pre || self.allow_prerelease,
|
||||
),
|
||||
)
|
||||
})
|
||||
.map(|(source, _)| *source)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !conflicts_with_this.is_empty()
|
||||
&& (info.using.is_some()
|
||||
|| conflicts_with_this
|
||||
.iter()
|
||||
.any(|x| self.dependencies[*x].using.is_some()))
|
||||
{
|
||||
let vec = conflicts.entry(name.into()).or_default();
|
||||
for source in conflicts_with_this {
|
||||
vec.push(source.into())
|
||||
}
|
||||
if !conflicts_with_this.is_empty()
|
||||
&& (info.using.is_some()
|
||||
|| conflicts_with_this
|
||||
.iter()
|
||||
.any(|x| self.dependencies[*x].using.is_some()))
|
||||
{
|
||||
let vec = conflicts.entry(name.into()).or_default();
|
||||
for source in conflicts_with_this {
|
||||
vec.push(source.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ impl<'env> Builder<'env> {
|
|||
})
|
||||
};
|
||||
|
||||
debug!("removable packages: {:?}", removable);
|
||||
debug!("removable packages: {removable:?}");
|
||||
// nothing can be removed
|
||||
if removable.is_empty() {
|
||||
return;
|
||||
|
|
@ -493,7 +493,7 @@ impl<'env> Builder<'env> {
|
|||
})
|
||||
};
|
||||
|
||||
debug!("using packages: {:?}", using_packages);
|
||||
debug!("using packages: {using_packages:?}");
|
||||
|
||||
// weep
|
||||
for locked in unity_project.locked_packages() {
|
||||
|
|
@ -587,7 +587,7 @@ impl UnityProject {
|
|||
}
|
||||
|
||||
// remove packages
|
||||
let remove_temp_dir = format!("{}/{}", PKG_TEMP_DIR, uuid::Uuid::new_v4());
|
||||
let remove_temp_dir = format!("{PKG_TEMP_DIR}/{}", uuid::Uuid::new_v4());
|
||||
let remove_temp_dir = Path::new(&remove_temp_dir);
|
||||
|
||||
self.io.create_dir_all(remove_temp_dir).await?;
|
||||
|
|
@ -605,14 +605,14 @@ impl UnityProject {
|
|||
for (name, change) in &request.package_changes {
|
||||
match change {
|
||||
PackageChange::Install(change) => {
|
||||
if let Some(package) = change.package {
|
||||
if change.add_to_locked {
|
||||
self.manifest.add_locked(
|
||||
package.name(),
|
||||
package.version().clone(),
|
||||
package.vpm_dependencies().clone(),
|
||||
);
|
||||
}
|
||||
if let Some(package) = change.package
|
||||
&& change.add_to_locked
|
||||
{
|
||||
self.manifest.add_locked(
|
||||
package.name(),
|
||||
package.version().clone(),
|
||||
package.vpm_dependencies().clone(),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(version) = &change.to_dependencies {
|
||||
|
|
@ -692,7 +692,7 @@ async fn move_packages_to_temp<'a>(
|
|||
return Ok(moved.into_iter().collect());
|
||||
|
||||
async fn move_package(io: &DefaultProjectIo, name: &str, temp_dir: &Path) -> io::Result<bool> {
|
||||
let package_dir = format!("Packages/{}", name);
|
||||
let package_dir = format!("Packages/{name}");
|
||||
let package_dir = Path::new(&package_dir);
|
||||
let copied_dir = temp_dir.join(name);
|
||||
|
||||
|
|
@ -705,14 +705,14 @@ async fn move_packages_to_temp<'a>(
|
|||
match io.create_dir_all(&moved).await {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
log::error!(gui_toast = false; "error creating directory {}: {}", moved.display(), e);
|
||||
log::error!(gui_toast = false; "error creating directory {}: {e}", moved.display());
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(name) = original.file_name().unwrap().to_str() {
|
||||
moved.pop();
|
||||
moved.push(format!("{}{}", REMOVED_FILE_PREFIX, name));
|
||||
moved.push(format!("{REMOVED_FILE_PREFIX}{name}"));
|
||||
}
|
||||
log::trace!("move {} to {}", original.display(), moved.display());
|
||||
|
||||
|
|
@ -720,7 +720,7 @@ async fn move_packages_to_temp<'a>(
|
|||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
// ignore error
|
||||
log::error!(gui_toast = false; "error moving {} to {}: {}", original.display(), moved.display(), e);
|
||||
log::error!(gui_toast = false; "error moving {} to {}: {e}", original.display(), moved.display());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -742,7 +742,7 @@ async fn move_packages_to_temp<'a>(
|
|||
|
||||
async fn restore_remove(io: &DefaultProjectIo, temp_dir: &Path, names: impl Iterator<Item = &str>) {
|
||||
for name in names {
|
||||
let package_dir = format!("Packages/{}", name);
|
||||
let package_dir = format!("Packages/{name}");
|
||||
let package_dir = Path::new(&package_dir);
|
||||
let temp_package_dir = temp_dir.join(name);
|
||||
if io.metadata(&temp_package_dir).await.is_err() {
|
||||
|
|
@ -779,13 +779,11 @@ async fn restore_remove(io: &DefaultProjectIo, temp_dir: &Path, names: impl Iter
|
|||
.await
|
||||
.map(|x| !x.is_dir())
|
||||
.unwrap_or(false)
|
||||
&& let Some(name) = original.file_name().unwrap().to_str()
|
||||
&& let Some(stripped) = name.strip_prefix(REMOVED_FILE_PREFIX)
|
||||
{
|
||||
if let Some(name) = original.file_name().unwrap().to_str() {
|
||||
if let Some(stripped) = name.strip_prefix(REMOVED_FILE_PREFIX) {
|
||||
let moved = original.parent().unwrap().join(stripped);
|
||||
io.rename(&original, &moved).await.ok();
|
||||
}
|
||||
}
|
||||
let moved = original.parent().unwrap().join(stripped);
|
||||
io.rename(&original, &moved).await.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -842,23 +840,23 @@ async fn remove_assets(
|
|||
building.push(".meta");
|
||||
let meta = PathBuf::from(building);
|
||||
|
||||
if let Some(err) = io.remove_file(&meta).await.err() {
|
||||
if !matches!(err.kind(), io::ErrorKind::NotFound) {
|
||||
log::error!("error removing legacy asset at {}: {}", meta.display(), err);
|
||||
}
|
||||
if let Some(err) = io.remove_file(&meta).await.err()
|
||||
&& !matches!(err.kind(), io::ErrorKind::NotFound)
|
||||
{
|
||||
log::error!("error removing legacy asset at {}: {err}", meta.display());
|
||||
}
|
||||
}
|
||||
|
||||
async fn remove_file(io: &DefaultProjectIo, path: &Path) {
|
||||
if let Some(err) = io.remove_file(path).await.err() {
|
||||
log::error!("error removing legacy asset at {}: {}", path.display(), err);
|
||||
log::error!("error removing legacy asset at {}: {err}", path.display());
|
||||
}
|
||||
remove_meta_file(io, path.to_owned()).await;
|
||||
}
|
||||
|
||||
async fn remove_folder(io: &DefaultProjectIo, path: &Path) {
|
||||
if let Some(err) = io.remove_dir_all(path).await.err() {
|
||||
log::error!("error removing legacy asset at {}: {}", path.display(), err);
|
||||
log::error!("error removing legacy asset at {}: {err}", path.display());
|
||||
}
|
||||
remove_meta_file(io, path.to_owned()).await;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl fmt::Display for ReinstalPackagesError {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ReinstalPackagesError::NotInstalled { package_name } => {
|
||||
write!(f, "Package {} is not installed", package_name)
|
||||
write!(f, "Package {package_name} is not installed")
|
||||
}
|
||||
ReinstalPackagesError::DependenciesNotFound { dependencies } => {
|
||||
write!(f, "Following dependencies are not found: ")?;
|
||||
|
|
|
|||
|
|
@ -57,13 +57,13 @@ impl VpmManifest {
|
|||
.map(|x| &x.version)
|
||||
}
|
||||
|
||||
pub(super) fn all_locked(&self) -> impl Iterator<Item = LockedDependencyInfo> {
|
||||
pub(super) fn all_locked(&self) -> impl Iterator<Item = LockedDependencyInfo<'_>> {
|
||||
self.controller.locked.iter().map(|(name, dep)| {
|
||||
LockedDependencyInfo::new(name.as_ref(), &dep.version, dep.dependencies.as_ref())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn get_locked(&self, package: &str) -> Option<LockedDependencyInfo> {
|
||||
pub(super) fn get_locked(&self, package: &str) -> Option<LockedDependencyInfo<'_>> {
|
||||
self.controller
|
||||
.locked
|
||||
.get_key_value(package)
|
||||
|
|
|
|||
|
|
@ -411,11 +411,11 @@ where
|
|||
{
|
||||
Err(e) => Err(e),
|
||||
Ok(Some(key)) => {
|
||||
if let Some(as_str) = as_str {
|
||||
if !self.existing_keys.insert(as_str) {
|
||||
let _: IgnoredAny = self.next_value()?;
|
||||
continue;
|
||||
}
|
||||
if let Some(as_str) = as_str
|
||||
&& !self.existing_keys.insert(as_str)
|
||||
{
|
||||
let _: IgnoredAny = self.next_value()?;
|
||||
continue;
|
||||
}
|
||||
Ok(Some(key))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ pub(crate) async fn extract_zip(
|
|||
if !is_complete_relative(filename.as_ref()) {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
format!("directory traversal detected: {}", filename),
|
||||
format!("directory traversal detected: {filename}"),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ pub(crate) fn walk_dir_relative<IO: IoTrait>(
|
|||
},
|
||||
}
|
||||
futures.push(Either::Right(next_phase(read_dir_iter, dir_relative).map(FutureResult::<IO>::Right)));
|
||||
log::trace!("yield: {:?}", new_relative_path);
|
||||
log::trace!("yield: {new_relative_path:?}");
|
||||
yield (new_relative_path, entry);
|
||||
},
|
||||
}
|
||||
|
|
@ -292,7 +292,7 @@ pub(crate) async fn read_json_file<T: serde::de::DeserializeOwned>(
|
|||
Ok(loaded) => Ok(loaded),
|
||||
Err(e) => Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
format!("syntax error loading {}: {}", path.display(), e),
|
||||
format!("syntax error loading {}: {e}", path.display()),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ mod tests {
|
|||
fn test(greater: &str, lesser: &str) {
|
||||
let greater = Version::from_str(greater).expect(greater);
|
||||
let lesser = Version::from_str(lesser).expect(lesser);
|
||||
assert!(greater > lesser, "{} > {}", greater, lesser);
|
||||
assert!(greater > lesser, "{greater} > {lesser}");
|
||||
}
|
||||
// test set are from node-semver
|
||||
// Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
|
|
|||
|
|
@ -750,16 +750,14 @@ mod tests {
|
|||
fn test(range: &str, version: &str) {
|
||||
let range = VersionRange::from_str(range).expect(range);
|
||||
let version = Version::from_str(version).expect(version);
|
||||
assert!(range.matches(&version), "{} matches {}", range, version);
|
||||
assert!(range.matches(&version), "{range} matches {version}");
|
||||
}
|
||||
fn test_pre(range: &str, version: &str) {
|
||||
let range = VersionRange::from_str(range).expect(range);
|
||||
let version = Version::from_str(version).expect(version);
|
||||
assert!(
|
||||
range.match_pre(&version, PrereleaseAcceptance::Allow),
|
||||
"{} matches {}",
|
||||
range,
|
||||
version
|
||||
"{range} matches {version}"
|
||||
);
|
||||
}
|
||||
// test set are from node-semver
|
||||
|
|
@ -911,9 +909,7 @@ mod tests {
|
|||
let version = Version::from_str(version).expect(version);
|
||||
assert!(
|
||||
!range.matches(&version),
|
||||
"{} should not matches {}",
|
||||
range,
|
||||
version
|
||||
"{range} should not matches {version}"
|
||||
);
|
||||
}
|
||||
fn test_pre(range: &str, version: &str) {
|
||||
|
|
@ -921,9 +917,7 @@ mod tests {
|
|||
let version = Version::from_str(version).expect(version);
|
||||
assert!(
|
||||
!range.match_pre(&version, PrereleaseAcceptance::Allow),
|
||||
"{} should not matches {}",
|
||||
range,
|
||||
version
|
||||
"{range} should not matches {version}"
|
||||
);
|
||||
}
|
||||
// test set are from node-semver
|
||||
|
|
|
|||
|
|
@ -86,10 +86,10 @@ impl VersionSelector<'_> {
|
|||
return false;
|
||||
}
|
||||
|
||||
if let Some(unity) = project_unity {
|
||||
if !unity_compatible(package, unity) {
|
||||
return false;
|
||||
}
|
||||
if let Some(unity) = project_unity
|
||||
&& !unity_compatible(package, unity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
|
|
|
|||
|
|
@ -888,7 +888,7 @@ fn not_found_err() {
|
|||
assert_eq!(dependencies.len(), 1);
|
||||
assert_eq!(dependencies[0].0.as_ref(), "com.vrchat.base");
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
_ => panic!("unexpected error: {err:?}"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -921,7 +921,7 @@ fn updating_non_locked_package_should_cause_error() {
|
|||
AddPackageErr::UpgradingNonLockedPackage { package_name } => {
|
||||
assert_eq!(package_name.as_ref(), "com.vrchat.avatars");
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
_ => panic!("unexpected error: {err:?}"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,20 +29,20 @@ pub struct PackageCollection {
|
|||
}
|
||||
|
||||
impl PackageCollection {
|
||||
pub fn get_package(&self, name: &str, version: Version) -> PackageInfo {
|
||||
pub fn get_package(&self, name: &str, version: Version) -> PackageInfo<'_> {
|
||||
self.find_package_by_name(name, VersionSelector::specific_version(&version))
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl vrc_get_vpm::PackageCollection for PackageCollection {
|
||||
fn get_all_packages(&self) -> impl Iterator<Item = PackageInfo> {
|
||||
fn get_all_packages(&self) -> impl Iterator<Item = PackageInfo<'_>> {
|
||||
self.packages
|
||||
.iter()
|
||||
.map(|(json, path)| PackageInfo::local(json, path))
|
||||
}
|
||||
|
||||
fn find_packages(&self, package: &str) -> impl Iterator<Item = PackageInfo> {
|
||||
fn find_packages(&self, package: &str) -> impl Iterator<Item = PackageInfo<'_>> {
|
||||
self.get_all_packages()
|
||||
.filter(move |pkg| pkg.name() == package)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,10 +81,8 @@ impl VirtualProjectBuilder {
|
|||
name: &str,
|
||||
package_json: impl Into<String>,
|
||||
) -> &mut VirtualProjectBuilder {
|
||||
self.files.insert(
|
||||
format!("Packages/{}/package.json", name),
|
||||
package_json.into(),
|
||||
);
|
||||
self.files
|
||||
.insert(format!("Packages/{name}/package.json"), package_json.into());
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ fn confirm_prompt(msg: &str) -> bool {
|
|||
let mut buf = String::new();
|
||||
loop {
|
||||
// prompt
|
||||
write!(stdout, "{} [y/n] ", msg)?;
|
||||
write!(stdout, "{msg} [y/n] ")?;
|
||||
stdout.flush()?;
|
||||
|
||||
buf.clear();
|
||||
|
|
@ -228,7 +228,7 @@ fn print_prompt_install(changes: &PendingProjectChanges) {
|
|||
if !adding_to_dependencies.is_empty() {
|
||||
println!("You're adding the following packages to dependencies:");
|
||||
for (name, range) in &adding_to_dependencies {
|
||||
println!("- {} version {}", name, range);
|
||||
println!("- {name} version {range}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ fn print_prompt_install(changes: &PendingProjectChanges) {
|
|||
RemoveReason::Legacy => "legacy",
|
||||
RemoveReason::Unused => "unused",
|
||||
};
|
||||
println!("- {} (removed since {})", name, reason_name);
|
||||
println!("- {name} (removed since {reason_name})");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ fn print_prompt_install(changes: &PendingProjectChanges) {
|
|||
if unity_conflicts.peek().is_some() {
|
||||
println!("**Those packages are incompatible with your unity version**");
|
||||
for package in unity_conflicts {
|
||||
println!("- {}", package);
|
||||
println!("- {package}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -302,7 +302,7 @@ fn print_prompt_install(changes: &PendingProjectChanges) {
|
|||
println!("Those directory name conflicts with installing package,");
|
||||
println!("or same packages are installed in those directories.");
|
||||
for directory in unlocked_conflicts {
|
||||
println!("- Packages/{}", directory);
|
||||
println!("- Packages/{directory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -343,12 +343,11 @@ fn require_prompt_for_install(
|
|||
};
|
||||
|
||||
// if we're installing package,
|
||||
if let Some(package) = install.install_package() {
|
||||
if let Some(request_version) = version {
|
||||
if request_version != package.version() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if let Some(package) = install.install_package()
|
||||
&& let Some(request_version) = version
|
||||
&& request_version != package.version()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
|
|
@ -733,10 +732,10 @@ impl Outdated {
|
|||
|
||||
for locked in unity.all_packages() {
|
||||
for (name, range) in locked.dependencies() {
|
||||
if let Some((outdated, _)) = outdated_packages.get(name.as_ref()) {
|
||||
if !range.matches(outdated.version()) {
|
||||
outdated_packages.remove(name.as_ref());
|
||||
}
|
||||
if let Some((outdated, _)) = outdated_packages.get(name.as_ref())
|
||||
&& !range.matches(outdated.version())
|
||||
{
|
||||
outdated_packages.remove(name.as_ref());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -745,9 +744,7 @@ impl Outdated {
|
|||
0 => {
|
||||
for (name, (found, installed)) in &outdated_packages {
|
||||
println!(
|
||||
"{}: installed: {}, found: {}",
|
||||
name,
|
||||
installed,
|
||||
"{name}: installed: {installed}, found: {}",
|
||||
&found.version()
|
||||
);
|
||||
}
|
||||
|
|
@ -862,7 +859,7 @@ impl Upgrade {
|
|||
.exit_context("upgrading packages");
|
||||
|
||||
for (name, version) in updates {
|
||||
println!("upgraded {} to {}", name, version);
|
||||
println!("upgraded {name} to {version}");
|
||||
}
|
||||
|
||||
update_project_last_modified(&io, unity.project_dir()).await;
|
||||
|
|
@ -939,7 +936,7 @@ impl Downgrade {
|
|||
.exit_context("upgrading packages");
|
||||
|
||||
for (name, version) in downgrades {
|
||||
println!("downgraded {} to {}", name, version);
|
||||
println!("downgraded {name} to {version}");
|
||||
}
|
||||
|
||||
update_project_last_modified(&io, unity.project_dir()).await;
|
||||
|
|
@ -1002,7 +999,7 @@ impl Search {
|
|||
println!("{} version {}", x.name(), x.version());
|
||||
}
|
||||
if let Some(description) = x.package_json().description() {
|
||||
println!("{}", description);
|
||||
println!("{description}");
|
||||
}
|
||||
println!();
|
||||
}
|
||||
|
|
@ -1293,12 +1290,12 @@ impl RepoPackages {
|
|||
versions.get_latest_may_yanked(VersionSelector::latest_for(None, true))
|
||||
{
|
||||
if let Some(display_name) = pkg.display_name() {
|
||||
println!("{} | {}", display_name, pkg.name());
|
||||
println!("{display_name} | {}", pkg.name());
|
||||
} else {
|
||||
println!("{}", pkg.name());
|
||||
}
|
||||
if let Some(description) = pkg.description() {
|
||||
println!("{}", description);
|
||||
println!("{description}");
|
||||
}
|
||||
let mut versions = versions.all_versions().collect::<Vec<_>>();
|
||||
versions.sort_by_key(|pkg| pkg.version());
|
||||
|
|
@ -1381,7 +1378,7 @@ impl RepoImport {
|
|||
}
|
||||
println!("The following lines are invalid and will be ignored:");
|
||||
for line in result.unparseable_lines() {
|
||||
println!("- {}", line);
|
||||
println!("- {line}");
|
||||
}
|
||||
|
||||
if self.yes {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ impl ProjectList {
|
|||
.unwrap_or("unknown".into());
|
||||
|
||||
println!("{name}:");
|
||||
println!(" Path: {}", path);
|
||||
println!(" Path: {path}");
|
||||
println!(" Unity: {unity_version}");
|
||||
println!(" Target: {}", project.project_type());
|
||||
println!(" Is Favorite: {}", project.favorite());
|
||||
|
|
@ -209,9 +209,9 @@ impl UnityList {
|
|||
for unity in unity_installations.iter() {
|
||||
if let Some(path) = unity.path() {
|
||||
if let Some(unity_version) = unity.version() {
|
||||
println!("version {} at {}", unity_version, path);
|
||||
println!("version {unity_version} at {path}");
|
||||
} else {
|
||||
println!("unknown version at {}", path);
|
||||
println!("unknown version at {path}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ pub(crate) fn create_client(offline: bool) -> Option<Client> {
|
|||
author = author
|
||||
);
|
||||
|
||||
log::debug!("using user agent: {}", user_agent);
|
||||
log::debug!("using user agent: {user_agent}");
|
||||
|
||||
Some(
|
||||
Client::builder()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue