copy files
This commit is contained in:
@@ -14,10 +14,10 @@ use crate::{
|
||||
domain::warren::{
|
||||
models::{
|
||||
file::{
|
||||
AbsoluteFilePath, CatError, CatRequest, File, FileMimeType, FileName, FilePath,
|
||||
FileStream, FileType, LsError, LsRequest, LsResponse, MkdirError, MkdirRequest,
|
||||
MvError, MvRequest, RelativeFilePath, RmError, RmRequest, SaveError, SaveRequest,
|
||||
SaveResponse, TouchError, TouchRequest,
|
||||
AbsoluteFilePath, CatError, CatRequest, CpError, CpRequest, CpResponse, File,
|
||||
FileMimeType, FileName, FilePath, FileStream, FileType, LsError, LsRequest,
|
||||
LsResponse, MkdirError, MkdirRequest, MvError, MvRequest, RelativeFilePath,
|
||||
RmError, RmRequest, SaveError, SaveRequest, SaveResponse, TouchError, TouchRequest,
|
||||
},
|
||||
warren::UploadFileStream,
|
||||
},
|
||||
@@ -242,7 +242,20 @@ impl FileSystem {
|
||||
async fn touch(&self, path: &AbsoluteFilePath) -> io::Result<()> {
|
||||
let path = self.get_target_path(path);
|
||||
|
||||
tokio::fs::File::create(&path).await.map(|_| ())
|
||||
fs::File::create(&path).await.map(|_| ())
|
||||
}
|
||||
|
||||
async fn cp(
|
||||
&self,
|
||||
path: AbsoluteFilePath,
|
||||
target_path: AbsoluteFilePath,
|
||||
) -> io::Result<CpResponse> {
|
||||
let fs_current_path = self.get_target_path(&path);
|
||||
let fs_target_path = self.get_target_path(&target_path);
|
||||
|
||||
fs::copy(fs_current_path, fs_target_path).await?;
|
||||
|
||||
Ok(CpResponse::new(path, target_path))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,6 +326,13 @@ impl FileSystemRepository for FileSystem {
|
||||
let (path, mut stream) = request.unpack();
|
||||
Ok(self.save(&path, &mut stream).await.map(SaveResponse::new)?)
|
||||
}
|
||||
|
||||
async fn cp(&self, request: CpRequest) -> Result<CpResponse, CpError> {
|
||||
let (path, target_path) = request.into_paths();
|
||||
self.cp(path, target_path)
|
||||
.await
|
||||
.map_err(|e| CpError::Unknown(e.into()))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Use `DirEntry::metadata` once `target=x86_64-unknown-linux-musl` updates from musl 1.2.3 to 1.2.5
|
||||
|
||||
Reference in New Issue
Block a user