Merge pull request #1833 from zed-industries/add-channel-to-db

Added channel info to database directories
This commit is contained in:
Mikayla Maki 2022-10-28 11:54:46 -07:00 committed by GitHub
commit 8a095d0a55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View file

@ -25,9 +25,9 @@ pub struct RealDb {
impl Db {
/// Open or create a database at the given directory path.
pub fn open(db_dir: &Path) -> Self {
pub fn open(db_dir: &Path, channel: &'static str) -> Self {
// Use 0 for now. Will implement incrementing and clearing of old db files soon TM
let current_db_dir = db_dir.join(Path::new("0"));
let current_db_dir = db_dir.join(Path::new(&format!("0-{}", channel)));
fs::create_dir_all(&current_db_dir)
.expect("Should be able to create the database directory");
let db_path = current_db_dir.join(Path::new("db.sqlite"));

View file

@ -39,7 +39,10 @@ use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJson
use theme::ThemeRegistry;
use util::{ResultExt, TryFutureExt};
use workspace::{self, AppState, ItemHandle, NewFile, OpenPaths, Workspace};
use zed::{self, build_window_options, initialize_workspace, languages, menus, RELEASE_CHANNEL};
use zed::{
self, build_window_options, initialize_workspace, languages, menus, RELEASE_CHANNEL,
RELEASE_CHANNEL_NAME,
};
fn main() {
let http = http::client();
@ -52,9 +55,10 @@ fn main() {
.or_else(|| app.platform().app_version().ok())
.map_or("dev".to_string(), |v| v.to_string());
init_panic_hook(app_version, http.clone(), app.background());
let db = app
.background()
.spawn(async move { project::Db::open(&*zed::paths::DB_DIR) });
let db = app.background().spawn(async move {
project::Db::open(&*zed::paths::DB_DIR, RELEASE_CHANNEL_NAME.as_str())
});
load_embedded_fonts(&app);

View file

@ -71,7 +71,7 @@ actions!(
const MIN_FONT_SIZE: f32 = 6.0;
lazy_static! {
static ref RELEASE_CHANNEL_NAME: String =
pub static ref RELEASE_CHANNEL_NAME: String =
env::var("ZED_RELEASE_CHANNEL").unwrap_or(include_str!("../RELEASE_CHANNEL").to_string());
pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME.as_str() {
"dev" => ReleaseChannel::Dev,