feat(web): panneau Fichiers — navigation projet + téléchargements fichier/dossier ZIP — #211
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::time::UNIX_EPOCH;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::ports::{DirEntry, FileMetadata, FileSystem, FsError, RemotePath};
|
||||
@ -62,9 +63,17 @@ impl FileSystem for LocalFileSystem {
|
||||
is_file: meta.is_file(),
|
||||
is_dir: meta.is_dir(),
|
||||
len: Some(meta.len()),
|
||||
modified_at_ms: modified_at_ms(&meta),
|
||||
})
|
||||
}
|
||||
|
||||
async fn canonicalize(&self, path: &RemotePath) -> Result<RemotePath, FsError> {
|
||||
fs::canonicalize(path.as_str())
|
||||
.await
|
||||
.map(|path| RemotePath::new(path.to_string_lossy().into_owned()))
|
||||
.map_err(|e| map_io(path, &e))
|
||||
}
|
||||
|
||||
async fn remove_file(&self, path: &RemotePath) -> Result<(), FsError> {
|
||||
match fs::remove_file(path.as_str()).await {
|
||||
Ok(()) => Ok(()),
|
||||
@ -103,6 +112,13 @@ impl FileSystem for LocalFileSystem {
|
||||
}
|
||||
}
|
||||
|
||||
fn modified_at_ms(meta: &std::fs::Metadata) -> Option<u64> {
|
||||
meta.modified()
|
||||
.ok()
|
||||
.and_then(|modified| modified.duration_since(UNIX_EPOCH).ok())
|
||||
.map(|duration| duration.as_millis().min(u128::from(u64::MAX)) as u64)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
async fn symlink_impl(src: &Path, dst: &Path) -> io::Result<()> {
|
||||
fs::symlink(src, dst).await
|
||||
|
||||
Reference in New Issue
Block a user