从 GitHub 下载 Beta 安装包安装后,更新通道默认选中 Release, 因为 update-channel.json 状态文件不存在时会硬编码回退到 release。 新增 theseus::default_update_channel(),按编译期版本号判断:含预发布 后缀(如 1.0.2-beta7)默认 Beta,否则 Release。数据库渠道与设置页 渠道两处默认值统一改为调用它,保证两者一致。
This commit is contained in:
1 parent
0f35a5f707
commit
8b94e7dbbe
3 files changed
+15
-3
No files matched your search
@@ -33,7 +33,7 @@ pub use logger::start_logger;
|
||||
pub use state::db::{
|
||||
backup_current_app_db_for_update, beta_database_exists,
|
||||
copy_database_between_channels, copy_release_database_to_beta,
|
||||
current_app_database_path,
|
||||
current_app_database_path, default_update_channel,
|
||||
};
|
||||
pub use state::{DirectoryInfo, State};
|
||||
pub use storage::*;
|
||||
|
||||
@@ -304,6 +304,18 @@ async fn app_db_path(settings_dir: &Path) -> crate::Result<PathBuf> {
|
||||
Ok(settings_dir.join(channel).join(LEGACY_APP_DB_FILE))
|
||||
}
|
||||
|
||||
/// The update channel a fresh install should default to. Beta builds carry a
|
||||
/// pre-release version (e.g. `1.0.2-beta7`), so their installers should start
|
||||
/// on the Beta channel instead of silently falling back to Release.
|
||||
pub fn default_update_channel() -> &'static str {
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
if version.contains('-') {
|
||||
"beta"
|
||||
} else {
|
||||
"release"
|
||||
}
|
||||
}
|
||||
|
||||
async fn read_update_channel(
|
||||
settings_dir: &Path,
|
||||
) -> crate::Result<&'static str> {
|
||||
@@ -311,7 +323,7 @@ async fn read_update_channel(
|
||||
let contents = match tokio::fs::read_to_string(&path).await {
|
||||
Ok(contents) => contents,
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
|
||||
return Ok("release");
|
||||
return Ok(default_update_channel());
|
||||
}
|
||||
Err(error) => return Err(error.into()),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user