Skip to content

Commit b88848e

Browse files
authored
Rename open_rw->create_rw (#1573)
Follow-up to #1571 Reasoning outlined in this [discussion](#1571 (comment))
1 parent 473afac commit b88848e

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

scarb/src/compiler/helpers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn write_json(
109109
ws: &Workspace<'_>,
110110
value: impl Serialize,
111111
) -> Result<()> {
112-
let file = target_dir.open_rw(file_name, description, ws.config())?;
112+
let file = target_dir.create_rw(file_name, description, ws.config())?;
113113
let file = BufWriter::new(&*file);
114114
serde_json::to_writer(file, &value)
115115
.with_context(|| format!("failed to serialize {file_name}"))?;
@@ -123,7 +123,7 @@ pub fn write_string(
123123
ws: &Workspace<'_>,
124124
value: impl ToString,
125125
) -> Result<()> {
126-
let mut file = target_dir.open_rw(file_name, description, ws.config())?;
126+
let mut file = target_dir.create_rw(file_name, description, ws.config())?;
127127
file.write_all(value.to_string().as_bytes())?;
128128
Ok(())
129129
}

scarb/src/core/registry/client/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'c> RegistryClientCache<'c> {
154154
let dl_fs = self.dl_fs.clone();
155155
move |config: &Config| {
156156
let tarball_name = package.tarball_name();
157-
dl_fs.open_rw(&tarball_name, &tarball_name, config)
157+
dl_fs.create_rw(&tarball_name, &tarball_name, config)
158158
}
159159
});
160160

scarb/src/core/registry/client/http.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl<'c> IndexConfigManager<'c> {
304304
async fn save_in_cache(&self, index_config: &IndexConfig) -> Result<()> {
305305
let mut file = self
306306
.cache_fs
307-
.open_rw(&self.cache_file_name, &self.cache_file_name, self.config)?
307+
.create_rw(&self.cache_file_name, &self.cache_file_name, self.config)?
308308
.into_async();
309309
let json = serde_json::to_vec(index_config)?;
310310
file.write_all(&json).await?;

scarb/src/flock.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<'f> AdvisoryLock<'f> {
164164
let file_lock_arc = match slot.upgrade() {
165165
Some(arc) => arc,
166166
None => {
167-
let arc = Arc::new(self.filesystem.open_rw(
167+
let arc = Arc::new(self.filesystem.create_rw(
168168
&self.path,
169169
&self.description,
170170
self.config,
@@ -249,7 +249,7 @@ impl Filesystem {
249249
///
250250
/// The returned file can be accessed to look at the path and also has read/write access to
251251
/// the underlying file.
252-
pub fn open_rw(
252+
pub fn create_rw(
253253
&self,
254254
path: impl AsRef<Utf8Path>,
255255
description: &str,

scarb/src/ops/package.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn package_one_impl(
163163
let target_dir = ws.target_dir().child("package");
164164

165165
let mut dst =
166-
target_dir.open_rw(format!(".{filename}"), "package scratch space", ws.config())?;
166+
target_dir.create_rw(format!(".{filename}"), "package scratch space", ws.config())?;
167167

168168
dst.set_len(0)
169169
.with_context(|| format!("failed to truncate: {filename}"))?;

scarb/tests/flock.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ fn locking_build_artifacts() {
2525

2626
thread::scope(|s| {
2727
let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap();
28-
let lock = ws.target_dir().child(config.profile().to_string()).open_rw(
29-
"hello.sierra.json",
30-
"artifact",
31-
&config,
32-
);
28+
let lock = ws
29+
.target_dir()
30+
.child(config.profile().to_string())
31+
.create_rw("hello.sierra.json", "artifact", &config);
3332
let barrier = Arc::new(Barrier::new(2));
3433

3534
s.spawn({

0 commit comments

Comments
 (0)