Skip to content

Commit

Permalink
Fix updating credentials on different mounts/drives/volumes (#1334)
Browse files Browse the repository at this point in the history
* use dir for tmp_file_name

* add comment about change

* change to tmp_file_path

* clippy

* cqa
  • Loading branch information
quinchs committed Jun 5, 2024
1 parent a08cb51 commit f143df5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/branch/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use edgedb_tokio::get_project_dir;
use crate::commands::Options;
use crate::connect::Connection;
use crate::credentials;
use crate::platform::tmp_file_name;
use crate::platform::tmp_file_path;
use crate::portable::config::Config;
use crate::portable::options::InstanceName;
use crate::portable::project;
Expand Down Expand Up @@ -121,13 +121,14 @@ impl Context {
name: _name,
} if self.project_dir.is_some() => {
// only place to store the branch is the database file in the project
let path =
let stash_path =
project::stash_path(&fs::canonicalize(self.project_dir.as_ref().unwrap())?)?
.join("database");

let tmp = tmp_file_name(&path);
// ensure that the temp file is created in the same directory as the 'database' file
let tmp = tmp_file_path(&stash_path);
fs::write(&tmp, branch)?;
fs::rename(&tmp, &path)?;
fs::rename(&tmp, &stash_path)?;

Ok(())
}
Expand Down

0 comments on commit f143df5

Please sign in to comment.