Skip to content

Commit

Permalink
fix: dummy file attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ho-229 committed May 22, 2024
1 parent fe99890 commit c2d504e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions bin/ofs/src/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,8 @@ impl PathFilesystem for Fuse {
.await
.map_err(opendal_error2errno)?;

let metadata = Metadata::new(EntryMode::DIR);
let now = SystemTime::now();
let attr = metadata2file_attr(&metadata, now, self.uid, self.gid);
let attr = dummy_file_attr(FileType::Directory, now, self.uid, self.gid);

Ok(ReplyEntry { ttl: TTL, attr })
}
Expand Down Expand Up @@ -406,12 +405,7 @@ impl PathFilesystem for Fuse {
};

let now = SystemTime::now();
let metadata = self
.op
.stat(&path.to_string_lossy())
.await
.map_err(opendal_error2errno)?;
let attr = metadata2file_attr(&metadata, now, self.uid, self.gid);
let attr = dummy_file_attr(FileType::RegularFile, now, self.uid, self.gid);

let key = self
.opened_files
Expand Down Expand Up @@ -700,8 +694,7 @@ impl PathFilesystem for Fuse {
.map_err(opendal_error2errno)
});

let relative_path_metadata = Metadata::new(EntryMode::DIR);
let relative_path_attr = metadata2file_attr(&relative_path_metadata, now, uid, gid);
let relative_path_attr = dummy_file_attr(FileType::Directory, now, uid, gid);
let relative_paths = stream::iter([
Result::Ok(DirectoryEntryPlus {
kind: FileType::Directory,
Expand Down Expand Up @@ -795,10 +788,19 @@ fn metadata2file_attr(metadata: &Metadata, atime: SystemTime, uid: u32, gid: u32
let kind = entry_mode2file_type(metadata.mode());
FileAttr {
size: metadata.content_length(),
blocks: 0,
atime,
mtime: last_modified,
ctime: last_modified,
..dummy_file_attr(kind, atime, uid, gid)
}
}

const fn dummy_file_attr(kind: FileType, now: SystemTime, uid: u32, gid: u32) -> FileAttr {
FileAttr {
size: 0,
blocks: 0,
atime: now,
mtime: now,
ctime: now,
kind,
perm: fuse3::perm_from_mode_and_kind(kind, 0o775),
nlink: 0,
Expand Down

0 comments on commit c2d504e

Please sign in to comment.