Skip to content

Commit

Permalink
fixing entity not found issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Feb 28, 2024
1 parent 70d1e8e commit aaf0d5b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ libssh-rs = { version = "0.2.2", features = ["vendored"] }
libssh-rs-sys = "0.2.2"
flate2 = "1.0"
regex = "1.10.3"
libc = "0.2.153"

[dependencies.tauri]
version = "1.5.4"
Expand Down
27 changes: 20 additions & 7 deletions src-tauri/src/plugins/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ async fn write<R: Runtime>(
let sessions = app.state::<SessionManager>();
return Ok(sessions.with_session(device, |session| {
let sftp = session.sftp()?;
let mut file = sftp.open(
&path, 0o1101, /*O_WRONLY | O_CREAT | O_TRUNC on Linux*/
0o644,
)?;
let mut file =
sftp.open(&path, libc::O_WRONLY | libc::O_CREAT | libc::O_TRUNC, 0o644)?;
file.write_all(&content)?;
return Ok(());
})?);
Expand Down Expand Up @@ -126,9 +124,24 @@ async fn put<R: Runtime>(
let sessions = app.state::<SessionManager>();
return sessions.with_session(device, |session| {
let sftp = session.sftp()?;
let mut sfile =
sftp.open(&path, 0x0301 /*O_WRONLY | O_CREAT | O_TRUNC*/, 0o644)?;
let mut file = File::open(source.clone())?;
let mut sfile = sftp
.open(&path, libc::O_WRONLY | libc::O_CREAT | libc::O_TRUNC, 0o644)
.map_err(|e| {
let e: Error = e.into();
return match e {
Error::IO { code, message } => Error::IO {
code,
message: format!(
"Failed to open remote file {path} for writing: {message}"
),
},
e => e,
};
})?;
let mut file = File::open(source.clone()).map_err(|e| Error::IO {
code: e.kind(),
message: format!("Failed to open local file {source} for uploading: {e:?}"),
})?;
copy(&mut file, &mut sfile)?;
return Ok(());
});
Expand Down

0 comments on commit aaf0d5b

Please sign in to comment.