Still unable to figure out the issue.
I will show the code. First, I start off by calling this:
/// Saves the file with blocking
pub fn save_locally_blocking(&self) -> Result<PathBuf, FsError<String>> where Self: SyncIO {
let real_file_path = get_pathbuf(format!("{}{}.{}", *HYXE_VIRTUAL_DIR, generate_random_string(HYXE_FILE_OBFUSCATED_LEN), HYXE_FILE_EXT));
log::info!("[HyxeFile] Saving {} to {}", &self.file_name, real_file_path.to_str().unwrap());
SyncIO::serialize_to_local_fs(self, &real_file_path)
.and_then(|_| Ok(real_file_path))
}
The log::info! prints this out to the console:
[2020-07-15T13:12:55Z INFO hyxe_fs::hyxe_file] [HyxeFile] Saving password_file to C:\Users\Thomas Braun\.HyxeWave\virtual\UfRY5gIjHOUNvItWQsLZvbSlt6mZCUzO2Sn9DjBQd4ZxqS2muJ93SuI0Nt0azNxOxA0MyjuvDFXJaSNQtX17imhDp14mK0Cqa3acUAmkxgpTPree7lApfKphI2pajJfAi1xkK00zXawuGgu679HtBydApGv4efLTNPyRpDaBSXya8vXZoUv45CpNtTRLFJl40WqWtaZpxKrNtGtLaXphEZ5MwGCZg8.vxh
Then, the SyncIO::serialize ... function looks like this:
fn serialize_to_local_fs<P: AsRef<Path>>(&self, location: P) -> Result<(), FsError<String>> {
if let Some(parent_path) = location.as_ref().parent() {
crate::system_file_manager::make_dir_all_blocking(parent_path)?;
}
// the above executes successfully, then we go into the function below
crate::system_file_manager::write(self, location)
}
the crate::system_file_manager::write looks like this:
/// Writes a serializable object to the desired path
pub fn write<D: Sized + Serialize, P: AsRef<Path>>(object: &D, path: P) -> Result<(), FsError<String>> {
log::info!("J3");
std::fs::File::create(path)
.map_err(|err| FsError::IoError(err.to_string()))
.and_then(|file| {
log::info!("J4 || {:?}", &file);
let ref mut buf_writer = std::io::BufWriter::new(file);
log::info!("J5");
// change: use BufWriter, as it's "50x" faster https://stackoverflow.com/questions/49983101/serialization-of-large-struct-to-disk-with-serde-and-bincode-is-slow?noredirect=1&lq=1
bincode2::serialize_into(buf_writer, object).map_err(|err| FsError::IoError(err.to_string()))
})
}
The printlns! print only J3, then the closure exists with an error, specifically:
The system cannot find the path specified. (os error 3)
Not sure why this is the case