Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary File Parsing in read_file_from_workspace #4977

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 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 crates/gitbutler-repo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ gitbutler-cherry-pick.workspace = true
gitbutler-oxidize.workspace = true
uuid.workspace = true
itertools = "0.13"
base64 = "0.22.1"

[[test]]
name = "repo"
Expand Down
6 changes: 4 additions & 2 deletions crates/gitbutler-repo/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use gitbutler_command_context::CommandContext;
use gitbutler_project::Project;
use std::path::Path;

use base64::{engine::general_purpose, Engine as _};
use crate::{Config, RepositoryExt};

pub trait RepoCommands {
Expand Down Expand Up @@ -64,7 +64,9 @@ impl RepoCommands for Project {
let content = std::str::from_utf8(blob.content())?;
Ok(content.to_string())
} else {
anyhow::bail!("File is binary");
let binary_content = blob.content();
let encoded_content = general_purpose::STANDARD.encode(&binary_content);
Ok(encoded_content)
}
} else {
anyhow::bail!("Invalid workspace file");
Expand Down
1 change: 1 addition & 0 deletions crates/gitbutler-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ gitbutler-edit-mode.workspace = true
open = "5"
url = "2.5.2"


[dependencies.tauri]
version = "1.8.0"
features = [
Expand Down
5 changes: 2 additions & 3 deletions crates/gitbutler-tauri/src/repo.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pub mod commands {
use crate::error::{Error, UnmarkedError};
use anyhow::Result;
use gitbutler_branch_actions::RemoteBranchFile;
use gitbutler_command_context::CommandContext;
use gitbutler_project as projects;
use gitbutler_project::ProjectId;
use gitbutler_repo::RepoCommands;
Expand All @@ -9,8 +11,6 @@ pub mod commands {
use tauri::State;
use tracing::instrument;

use crate::error::{Error, UnmarkedError};

#[tauri::command(async)]
#[instrument(skip(projects), err(Debug))]
pub fn git_get_local_config(
Expand Down Expand Up @@ -76,7 +76,6 @@ pub mod commands {
relative_path: &Path,
) -> Result<String, Error> {
let project = projects.get(project_id)?;

Ok(project.read_file_from_workspace(relative_path)?)
}
}
Loading