Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
My name... Is Josuke Higashikata... And my memories from when I was b…
Browse files Browse the repository at this point in the history
…orn... Are long gone from this world... And they'll never... Come back... But even so, there's something I'm certain of. I am your son. No matter where I go, or what era I live in, that's something certain that I can believe in. Mom...
  • Loading branch information
raisfeld-ori committed Apr 23, 2024
1 parent 424a897 commit 002c7a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
7 changes: 3 additions & 4 deletions src-tauri/src/fs/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use serde_json::{Error, Value};
use std::fs::{read, write};
use crate::{authenticate_user, bytes_to_string, create_user};
use crate::fs::encryption::aes_decrypt;
use crate::fs::encryption::{aes_decrypt, aes_try_decrypt};
use crate::fs::utilities::get_user_dir;
use crate::fs::encryption::aes_encrypt;

Expand Down Expand Up @@ -176,8 +176,6 @@ impl File{
URL_SAFE);
let location = location.join(location_name);
let new_self = File {name: file_name, location};
// i have more important things to work on
// so just pretend this works with no issue
let _ = new_self.save(name, password, b"");
return new_self;
}
Expand All @@ -200,7 +198,8 @@ impl File{
pub fn read(&self, name: &str, password: &str) -> Option<Vec<u8>> {
let data = read(self.location.as_path());
if data.is_err(){return None;}
let data = aes_decrypt(name, password, &data.unwrap());
let data = data.unwrap();
let data = aes_decrypt(name, password, &data);
return Some(data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ import text from '../../../assets/pencil-square-icon.svg';
import arrowleft from '../../../assets/arrowleft.png'
import './file_system.css';

async function upload_file(update_fs: () => Promise<void>, set_files: React.Dispatch<React.SetStateAction<React.JSX.Element[]>>
, open_file: (file: string) => Promise<void>, is_selected: React.Dispatch<string>){
async function upload_file(update_fs: () => Promise<void>){
let name: string = await invoke('system_get', {key: 'name'});
let password: string = await invoke('system_get', {key: 'password'});
let file_selected = await open({});
if (Array.isArray(file_selected)){
for (let i = 0; i < file_selected.length;i++){
set_files(files => [...files, <File type={FileType.File} name={file_selected[i]} key={files.length + 1}
open_file={open_file} update_fs={update_fs} is_selected={is_selected}/>])
await invoke('upload_file', {name, password, file_path: file_selected});
}
await update_fs();
}
else if (file_selected == null){return;}
else{
make_file(name, password, file_selected, FileType.File);
// i should make a window for when upload_file fails, but it's not top priority for now
await invoke('upload_file', {name, password, filePath: file_selected});
await update_fs();
}
}
Expand Down Expand Up @@ -159,7 +158,7 @@ function file_system(open_file: (file: string) => Promise<void>) : AppInterface{
<button className='buttoncontextmenu' onClick={() => make_files(FileType.Directory)}>Create Folder</button>
<button className='buttoncontextmenu' onClick={() => make_files(FileType.File)}>create file</button>
<button className='buttoncontextmenu'
onClick={async () => await upload_file(update, set_files, open_file, set_selected)}>Upload File</button>
onClick={async () => await upload_file(update)}>Upload File</button>
{selected != '' ?
<div>
{/*<button className='buttoncontextmenu' >Rename</button>*/}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ export default function text_viewer(file_selected: string | null) : AppInterface
if (file_selected == null) {return;}
let name: string = await invoke('system_get', {key: 'name'});
let password: string = await invoke('system_get', {key: 'password'});
let data: string = await invoke('read_file', {file: file_selected, name, password});
let bytes = await invoke('read_file', {name, password,file: file_selected});
// i'l work on it later, idk what to do here for now
console.log(data);
if (bytes == null) {return;}
let data: string = await invoke('bytes_to_string', {bytes});
if (data == null) {return;}
set_text(data);
}
Expand Down

0 comments on commit 002c7a6

Please sign in to comment.