mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Use ~/Library for logs & packages on osx
This commit is contained in:
@@ -7,8 +7,14 @@ use anyhow::{bail, Result};
|
||||
use std::{fs, path::PathBuf, process::Command};
|
||||
|
||||
pub fn apply_package_impl<'a>(root_path: &PathBuf, app: &Manifest, pkg: &PathBuf, _runhooks: bool) -> Result<Manifest> {
|
||||
let tmp_path_new = format!("/tmp/velopack/{}/{}", app.id, shared::random_string(8));
|
||||
let tmp_path_old = format!("/tmp/velopack/{}/{}", app.id, shared::random_string(8));
|
||||
let mut cache_dir = std::env::home_dir().expect("Could not locate user home directory via $HOME or /etc/passwd");
|
||||
cache_dir.push("Library");
|
||||
cache_dir.push("Caches");
|
||||
cache_dir.push("velopack");
|
||||
cache_dir.push(&app.id);
|
||||
|
||||
let tmp_path_new = cache_dir.join(shared::random_string(8)).to_string_lossy();
|
||||
let tmp_path_old = cache_dir.join(shared::random_string(8)).to_string_lossy();
|
||||
let bundle = bundle::load_bundle_from_file(pkg)?;
|
||||
let manifest = bundle.read_manifest()?;
|
||||
|
||||
|
||||
@@ -6,6 +6,29 @@ pub fn trace_logger() {
|
||||
TermLogger::init(LevelFilter::Trace, get_config(), TerminalMode::Mixed, ColorChoice::Never).unwrap();
|
||||
}
|
||||
|
||||
pub fn default_log_location() -> PathBuf {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let mut my_dir = std::env::current_exe().unwrap();
|
||||
my_dir.pop();
|
||||
my_dir.pop();
|
||||
return my_dir.join("Velopack.log");
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
return std::path::Path::new("/tmp/velopack.log").to_path_buf();
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
#[allow(deprecated)]
|
||||
let mut user_home = std::env::home_dir().expect("Could not locate user home directory via $HOME or /etc/passwd");
|
||||
user_home.push("Library");
|
||||
user_home.push("Logs");
|
||||
user_home.push("velopack.log");
|
||||
return user_home;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup_logging(file: Option<&PathBuf>, console: bool, verbose: bool, nocolor: bool) -> Result<()> {
|
||||
let mut loggers: Vec<Box<dyn SharedLogger>> = Vec::new();
|
||||
let color_choice = if nocolor { ColorChoice::Never } else { ColorChoice::Auto };
|
||||
|
||||
@@ -87,7 +87,8 @@ fn main() -> Result<()> {
|
||||
if let Some(log_file) = log_file {
|
||||
logging::setup_logging(Some(&log_file), true, verbose, nocolor)?;
|
||||
} else {
|
||||
default_logging(verbose, nocolor, true)?;
|
||||
let default_log_file = logging::default_log_location();
|
||||
logging::setup_logging(Some(&default_log_file), true, verbose, nocolor)?;
|
||||
}
|
||||
|
||||
// change working directory to the parent directory of the exe
|
||||
@@ -184,20 +185,6 @@ fn uninstall(_matches: &ArgMatches) -> Result<()> {
|
||||
commands::uninstall(&root_path, &app, true)
|
||||
}
|
||||
|
||||
pub fn default_logging(verbose: bool, nocolor: bool, console: bool) -> Result<()> {
|
||||
#[cfg(windows)]
|
||||
let default_log_file = {
|
||||
let mut my_dir = env::current_exe().unwrap();
|
||||
my_dir.pop();
|
||||
my_dir.join("Velopack.log")
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
let default_log_file = std::path::Path::new("/tmp/velopack.log").to_path_buf();
|
||||
|
||||
logging::setup_logging(Some(&default_log_file), console, verbose, nocolor)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[test]
|
||||
fn test_start_command_supports_legacy_commands() {
|
||||
|
||||
@@ -33,7 +33,13 @@ namespace Velopack.Locators
|
||||
public override string? AppTempDir => CreateSubDirIfDoesNotExist(Utility.GetDefaultTempBaseDirectory(), AppId);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string? PackagesDir => CreateSubDirIfDoesNotExist(AppTempDir, "packages");
|
||||
public override string? PackagesDir => CreateSubDirIfDoesNotExist(CachesAppDir, "packages");
|
||||
|
||||
private string? CachesAppDir => CreateSubDirIfDoesNotExist(CachesVelopackDir, AppId);
|
||||
private string? CachesVelopackDir => CreateSubDirIfDoesNotExist(CachesDir, "velopack");
|
||||
private string? CachesDir => CreateSubDirIfDoesNotExist(LibraryDir, "Caches");
|
||||
private string? LibraryDir => CreateSubDirIfDoesNotExist(HomeDir, "Library");
|
||||
private string? HomeDir => Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string? Channel { get; }
|
||||
|
||||
Reference in New Issue
Block a user