Skip to content

Commit 68e2899

Browse files
committed
fix: symlink issues
1 parent 156f546 commit 68e2899

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
# Changelog
22

33
- [Changelog](#changelog)
4+
- [0.1.3](#013)
45
- [0.1.2](#012)
56
- [0.1.1](#011)
67
- [0.1.0](#010)
78

89
---
910

11+
## 0.1.3
12+
13+
Released on 25/10/2024
14+
15+
- set `modified` on `on_written`
16+
- symlink: write `target` as file content
17+
- symlink: fixed file mode
18+
1019
## 0.1.2
1120

1221
Released on 23/10/2024

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "remotefs-memory"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
authors = ["Christian Visintin <[email protected]>"]
55
edition = "2021"
66
license = "MIT"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<p align="center">~ A remotefs implementation for testing and simulation ~</p>
88

99
<p align="center">Developed by <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
10-
<p align="center">Current version: 0.1.2</p>
10+
<p align="center">Current version: 0.1.3</p>
1111

1212
<p align="center">
1313
<a href="https://opensource.org/licenses/MIT"

src/inode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ impl Inode {
4343
}
4444

4545
/// Create a new [`Inode`] with type **Symlink** with the given metadata and target.
46-
pub fn symlink(uid: u32, gid: u32, mode: UnixPex, target: PathBuf) -> Self {
46+
pub fn symlink(uid: u32, gid: u32, target: PathBuf) -> Self {
4747
Self {
4848
metadata: Metadata::default()
4949
.uid(uid)
5050
.gid(gid)
5151
.file_type(FileType::Symlink)
5252
.created(SystemTime::now())
5353
.accessed(SystemTime::now())
54-
.mode(mode)
55-
.symlink(target),
56-
content: None,
54+
.mode(UnixPex::from(0o777))
55+
.symlink(target.clone()),
56+
content: Some(target.to_string_lossy().as_bytes().to_vec()),
5757
}
5858
}
5959

src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ mod test;
5656

5757
use std::io::{Cursor, Read, Write};
5858
use std::path::{Path, PathBuf};
59+
use std::time::SystemTime;
5960

6061
pub use orange_trees::{node, Node, Tree};
6162
use remotefs::fs::stream::{StreamWriter, WriteAndSeek};
@@ -436,12 +437,7 @@ impl RemoteFs for MemoryFs {
436437
.unwrap_or_else(|| Path::new("/"))
437438
.to_path_buf();
438439

439-
let symlink = Inode::symlink(
440-
(self.get_uid)(),
441-
(self.get_gid)(),
442-
UnixPex::from(0o755),
443-
target.to_path_buf(),
444-
);
440+
let symlink = Inode::symlink((self.get_uid)(), (self.get_gid)(), target.to_path_buf());
445441

446442
let parent = self
447443
.tree
@@ -677,6 +673,8 @@ impl RemoteFs for MemoryFs {
677673
}
678674
WriteMode::Create => handle.data.get_ref().len() as u64,
679675
};
676+
value.metadata.modified = Some(SystemTime::now());
677+
680678
debug!("{:?} written {:?}", handle.path, value);
681679
node.set_value(value);
682680

0 commit comments

Comments
 (0)