Moved app data into user folders instead of system folders
This commit is contained in:
parent
617645e4f4
commit
8eaefb6dba
6 changed files with 118 additions and 112 deletions
|
@ -21,7 +21,7 @@ You can now start Polaris from the start menu or from your desktop, Polaris will
|
|||
|
||||
## Basic Configuration
|
||||
|
||||
All configuration is done by editing the file located at `C:\ProgramData\Polaris\polaris.toml`. Note that Polaris needs to be restarted for configuration changes to be taken into account.
|
||||
All configuration is done by editing the file located at `%appdata%\Roaming\Permafrost\Polaris\polaris.toml`. Note that Polaris needs to be restarted for configuration changes to be taken into account.
|
||||
|
||||
### Locating Your Music
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ Copy-Item .\web\ .\release\tmp\ -recurse
|
|||
""
|
||||
"Creating installer"
|
||||
candle -wx -ext WixUtilExtension -arch x64 -out .\release\tmp\installer.wixobj .\res\windows\installer\installer.wxs
|
||||
light -wx -ext WixUtilExtension -ext WixUIExtension -spdb -out .\release\Polaris_0.5.0.msi .\release\tmp\installer.wixobj
|
||||
light -wx -ext WixUtilExtension -ext WixUIExtension -spdb -sw1076 -out .\release\Polaris_0.5.0.msi .\release\tmp\installer.wixobj
|
||||
|
||||
"Cleaning up"
|
||||
Remove-Item -Recurse .\release\tmp
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version='1.0' encoding='windows-1252'?>
|
||||
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
|
||||
<Product Name='Polaris' Id='FE52CDDE-D982-42C9-B251-0621100244D5' UpgradeCode='959B405D-1553-411D-A4A2-CCD3E17BE0EC' Language='1033' Codepage='1252' Version='0.5.0' Manufacturer='Antoine Gersant'>
|
||||
<Product Name='Polaris' Id='4CA4E1DB-041F-4075-AE3D-34D3D0DFCEF6' UpgradeCode='C106B17B-95C0-49BB-BF1A-BC5CAD245076' Language='1033' Codepage='1252' Version='0.5.0' Manufacturer='Permafrost'>
|
||||
|
||||
<Package Id='*' Keywords='Installer' Platform='x64' InstallPrivileges='elevated' InstallScope='perMachine' Description='Polaris Installer' Manufacturer='Antoine Gersant' Languages='1033' Compressed='yes' SummaryCodepage='1252' />
|
||||
<Package Id='*' Keywords='Installer' Platform='x64' InstallScope='perMachine' Description='Polaris Installer' Manufacturer='Permafrost' Languages='1033' Compressed='yes' SummaryCodepage='1252' />
|
||||
|
||||
<MajorUpgrade DowngradeErrorMessage='A newer version of Polaris is already installed.' Schedule='afterInstallExecute' />
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
|||
|
||||
<Directory Id='TARGETDIR' Name='SourceDir'>
|
||||
<Directory Id='ProgramFiles64Folder' Name='PFiles'>
|
||||
<Directory Id='Permafrost' Name='Permafrost' FileSource='.'>
|
||||
<Directory Id='INSTALL_DIR' Name='Polaris' FileSource='.'>
|
||||
|
||||
<Component Id='MainExecutable' Guid='4E27209A-48B6-4A2A-8778-6383C83F0B24'>
|
||||
|
@ -106,26 +107,31 @@
|
|||
</Directory>
|
||||
</Directory>
|
||||
</Directory>
|
||||
</Directory>
|
||||
|
||||
<Directory Id='CommonAppDataFolder'>
|
||||
<Directory Id='AppDataFolder'>
|
||||
<Directory Id='AppDataPermafrost' Name='Permafrost'>
|
||||
<Directory Id='AppDataPolaris' Name='Polaris'>
|
||||
<Component Id='ConfigFile' Guid='FAF6D040-CFA2-4C56-B5EB-C8A3054294E0'>
|
||||
<Component Id='ConfigFile' Guid='3E84B72F-83FC-4B0B-B5FC-1347F1A03421'>
|
||||
<RegistryValue Root='HKCU' Key='Software\Permafrost\Polaris' Name='ConfigDirectory' Type='string' Value='[CONFIGDIRECTORY]' KeyPath='yes' />
|
||||
<File Source='polaris.toml'>
|
||||
<Permission GenericAll='yes' User='Everyone' />
|
||||
</File>
|
||||
<RemoveFolder Id='RemoveAppDataPolaris' Directory='AppDataPolaris' On='uninstall' />
|
||||
<RemoveFolder Id='RemoveAppDataPermafrost' Directory='AppDataPermafrost' On='uninstall' />
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
</Directory>
|
||||
|
||||
<Directory Id='DesktopFolder' Name='Desktop' />
|
||||
<Directory Id='StartupFolder' Name='Startup' />
|
||||
|
||||
<Directory Id='ProgramMenuFolder' Name='Programs'>
|
||||
<Directory Id='ProgramMenuDir' Name='Polaris'>
|
||||
<Component Id='ProgramMenuDir' Guid='9E677DF0-414B-481F-ACCC-73B2A38EC93A'>
|
||||
<Directory Id='ProgramMenuDir' Name='Permafrost'>
|
||||
<Component Id='ProgramMenuDir' Guid='228B33C8-2391-4693-A5AC-C1128F05C753'>
|
||||
<RemoveFolder Id='ProgramMenuDir' On='uninstall' />
|
||||
<RegistryValue Root='HKCU' Key='Software\Polaris' Name='ProgramMenuEntry' Type='string' Value='' KeyPath='yes' />
|
||||
<RegistryValue Root='HKCU' Key='Software\Permafrost\Polaris' Name='ProgramMenuEntry' Type='string' Value='' KeyPath='yes' />
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
|
@ -134,11 +140,11 @@
|
|||
|
||||
<!--Remove extra files after uninstall (db, thumbnails, etc.)-->
|
||||
<Property Id="EXTRADATAPATH">
|
||||
<RegistrySearch Root="HKLM" Key="SOFTWARE\Polaris" Name="ExtraDataPath" Type="raw" Id="ExtraDataPathSearch" />
|
||||
<RegistrySearch Root="HKCU" Key="Software\Permafrost\Polaris" Name="ExtraDataPath" Type="raw" Id="ExtraDataPathSearch" />
|
||||
</Property>
|
||||
<DirectoryRef Id="AppDataPolaris">
|
||||
<Component Id="CleanupExtraData" Guid="A74F0BA0-797F-4088-AF43-E7874AE679C7">
|
||||
<RegistryValue Root="HKLM" Key="SOFTWARE\Polaris" Name="ExtraDataPath" Type="string" Value="[AppDataPolaris]" KeyPath="yes" />
|
||||
<Component Id="CleanupExtraData" Guid="DF415F12-A1B4-48EE-98BC-E0B75AF556AD">
|
||||
<RegistryValue Root="HKCU" Key="Software\Permafrost\Polaris" Name="ExtraDataPath" Type="string" Value="[AppDataPolaris]" KeyPath="yes" />
|
||||
<util:RemoveFolderEx On="uninstall" Property="EXTRADATAPATH" />
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
|
|
@ -72,7 +72,7 @@ impl Config {
|
|||
if let Some(duration) = user_config.reindex_every_n_seconds {
|
||||
index_config.sleep_duration = duration;
|
||||
}
|
||||
let mut index_path = utils::get_cache_root()?;
|
||||
let mut index_path = utils::get_data_root()?;
|
||||
index_path.push(INDEX_FILE_NAME);
|
||||
index_config.path = index_path;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ fn hash(path: &Path, dimension: u32) -> u64 {
|
|||
|
||||
pub fn get_thumbnail(real_path: &Path, max_dimension: u32) -> Result<PathBuf> {
|
||||
|
||||
let mut out_path = utils::get_cache_root()?;
|
||||
let mut out_path = utils::get_data_root()?;
|
||||
out_path.push(THUMBNAILS_PATH);
|
||||
|
||||
let mut dir_builder = DirBuilder::new();
|
||||
|
|
14
src/utils.rs
14
src/utils.rs
|
@ -1,12 +1,13 @@
|
|||
use app_dirs::{AppDataType, data_root};
|
||||
use app_dirs::{AppDataType, AppInfo, app_root};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::fs;
|
||||
|
||||
use errors::*;
|
||||
|
||||
const APP_INFO: AppInfo = AppInfo{name: "Polaris", author: "Permafrost"};
|
||||
|
||||
pub fn get_config_root() -> Result<PathBuf> {
|
||||
if let Ok(mut root) = data_root(AppDataType::SharedConfig) {
|
||||
root.push("Polaris");
|
||||
if let Ok(root) = app_root(AppDataType::UserConfig, &APP_INFO) {
|
||||
fs::create_dir_all(&root)
|
||||
.chain_err(|| format!("opening shared config: {}", root.display()))?;
|
||||
return Ok(root);
|
||||
|
@ -14,14 +15,13 @@ pub fn get_config_root() -> Result<PathBuf> {
|
|||
bail!("Could not retrieve config directory root");
|
||||
}
|
||||
|
||||
pub fn get_cache_root() -> Result<PathBuf> {
|
||||
if let Ok(mut root) = data_root(AppDataType::SharedData) {
|
||||
root.push("Polaris");
|
||||
pub fn get_data_root() -> Result<PathBuf> {
|
||||
if let Ok(root) = app_root(AppDataType::UserData, &APP_INFO) {
|
||||
fs::create_dir_all(&root)
|
||||
.chain_err(|| format!("opening shared data: {}", root.display()))?;
|
||||
return Ok(root);
|
||||
}
|
||||
bail!("Could not retrieve cache directory root");
|
||||
bail!("Could not retrieve data directory root");
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
|
Loading…
Add table
Reference in a new issue