Skip to content

Commit

Permalink
fix: File::set_content parameter order
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus23 committed Apr 23, 2024
1 parent eec8e12 commit 0a7f9f7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion wnfs-wasm/src/fs/public/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ impl PublicFile {
let time = DateTime::<Utc>::from(time);

Ok(future_to_promise(async move {
file.set_content(time, content, &store)
file.prepare_next_revision()
.set_content(content, time, &store)
.await
.map_err(error("Cannot set file content"))?;

Expand Down
2 changes: 1 addition & 1 deletion wnfs/examples/tiered_blockstores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async fn main() -> Result<()> {

// `set_content` actually writes the data blocks to the blockstore in chunks,
// so for this we provide the `cold_store`.
file.set_content(Utc::now(), &video[..], forest, &cold_store, rng)
file.set_content(&video[..], Utc::now(), forest, &cold_store, rng)
.await?;

// When storing the hierarchy data blocks, we use the `hot_store`:
Expand Down
2 changes: 1 addition & 1 deletion wnfs/src/private/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ impl PrivateDirectory {
/// // Define the content that will replace what is already in the file
/// let new_file_content = b"print('hello world 2')";
/// // Set the contents of the file, waiting for result and expecting no errors
/// file.set_content(Utc::now(), &new_file_content[..], forest, store, rng)
/// file.set_content(&new_file_content[..], Utc::now(), forest, store, rng)
/// .await?;
/// // Read the file again
/// let result = root_dir.read(hello_py, true, forest, store).await?;
Expand Down
4 changes: 2 additions & 2 deletions wnfs/src/private/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ impl PrivateFile {
/// Sets the content of a file.
pub async fn set_content(
&mut self,
time: DateTime<Utc>,
content: impl AsyncRead + Unpin,
time: DateTime<Utc>,
forest: &mut impl PrivateForest,
store: &impl BlockStore,
rng: &mut impl CryptoRngCore,
Expand Down Expand Up @@ -1371,8 +1371,8 @@ mod proptests {
let mut file = PrivateFile::new(&forest.empty_name(), Utc::now(), rng);

file.set_content(
Utc::now(),
&mut Cursor::new(vec![5u8; length]),
Utc::now(),
forest,
&MemoryBlockStore::default(),
rng,
Expand Down
6 changes: 3 additions & 3 deletions wnfs/src/public/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ impl PublicFile {
}

/// Takes care of creating previous links, in case the current
/// directory was previously `.store()`ed.
/// In any case it'll try to give you ownership of the directory if possible,
/// file was previously `.store()`ed.
/// In any case it'll try to give you ownership of the file if possible,
/// otherwise it clones.
pub(crate) fn prepare_next_revision<'a>(self: &'a mut Arc<Self>) -> &'a mut Self {
pub fn prepare_next_revision<'a>(self: &'a mut Arc<Self>) -> &'a mut Self {
let Some(previous_cid) = self.persisted_as.get().cloned() else {
return Arc::make_mut(self);
};
Expand Down

0 comments on commit 0a7f9f7

Please sign in to comment.