chore: refactor code to remove unnecessary references in function signatures

This commit is contained in:
Nikita Galaiko 2023-11-07 12:42:38 +01:00 committed by GitButler
parent 90db1ae8c3
commit 735e23be83
7 changed files with 17 additions and 17 deletions

View File

@ -129,7 +129,7 @@ impl App {
&self,
project_id: &ProjectId,
session_id: &SessionId,
paths: &Option<Vec<path::PathBuf>>,
paths: Option<&[path::PathBuf]>,
) -> Result<HashMap<path::PathBuf, reader::Content>, Error> {
let session = self
.sessions_database

View File

@ -59,7 +59,7 @@ pub async fn list_session_files(
code: Code::Validation,
message: "Malformed project id".to_string(),
})?;
let files = app.list_session_files(&project_id, &session_id, &paths)?;
let files = app.list_session_files(&project_id, &session_id, paths.as_deref())?;
Ok(files)
}

View File

@ -38,7 +38,7 @@ impl<'reader> DeltasReader<'reader> {
pub fn read(
&self,
paths: &Option<Vec<&path::Path>>,
paths: Option<&[&path::Path]>,
) -> Result<HashMap<path::PathBuf, Vec<Delta>>> {
let deltas_dir = path::Path::new("session/deltas");
let files = self.reader.list_files(deltas_dir)?;

View File

@ -107,7 +107,7 @@ fn test_list_deltas_from_current_session() -> Result<()> {
let session_reader = sessions::Reader::open(&gb_repository, &current_session)?;
let deltas_reader = deltas::Reader::new(&session_reader);
let deltas = deltas_reader.read(&None)?;
let deltas = deltas_reader.read(None)?;
assert_eq!(deltas.len(), 1);
assert_eq!(
@ -142,7 +142,7 @@ fn test_list_deltas_from_flushed_session() -> Result<()> {
let session_reader = sessions::Reader::open(&gb_repository, &session.unwrap())?;
let deltas_reader = deltas::Reader::new(&session_reader);
let deltas = deltas_reader.read(&None)?;
let deltas = deltas_reader.read(None)?;
assert_eq!(deltas.len(), 1);
assert_eq!(
@ -166,7 +166,7 @@ fn test_list_files_from_current_session() -> Result<()> {
let current = gb_repository.get_or_create_current_session()?;
let reader = sessions::Reader::open(&gb_repository, &current)?;
let files = reader.files(&None)?;
let files = reader.files(None)?;
assert_eq!(files.len(), 1);
assert_eq!(
@ -191,7 +191,7 @@ fn test_list_files_from_flushed_session() -> Result<()> {
gb_repository.get_or_create_current_session()?;
let session = gb_repository.flush(&project_repository, None)?.unwrap();
let reader = sessions::Reader::open(&gb_repository, &session)?;
let files = reader.files(&None)?;
let files = reader.files(None)?;
assert_eq!(files.len(), 1);
assert_eq!(
@ -268,8 +268,8 @@ fn test_remote_syncronization() -> Result<()> {
let session_reader = sessions::Reader::open(&case_two.gb_repository, &sessions_two[0])?;
let deltas_reader = deltas::Reader::new(&session_reader);
let deltas = deltas_reader.read(&None)?;
let files = session_reader.files(&None)?;
let deltas = deltas_reader.read(None)?;
let files = session_reader.files(None)?;
assert_eq!(deltas.len(), 1);
assert_eq!(files.len(), 1);
assert_eq!(

View File

@ -84,7 +84,7 @@ impl<'reader> SessionReader<'reader> {
pub fn files(
&self,
paths: &Option<Vec<path::PathBuf>>,
paths: Option<&[path::PathBuf]>,
) -> Result<HashMap<path::PathBuf, reader::Content>> {
let files = self.previous_reader.list_files(path::Path::new("wd"))?;
let mut files_with_content = HashMap::new();

View File

@ -139,7 +139,7 @@ impl Handler {
let deltas_reader = deltas::Reader::new(&session_reader);
for (file_path, deltas) in deltas_reader
.read(&None)
.read(None)
.context("could not list deltas for session")?
{
let delta_events = self.index_deltas(project_id, &session.id, &file_path, &deltas)?;

View File

@ -570,7 +570,7 @@ mod test {
for session in &mut *sessions_slice {
let session_reader = sessions::Reader::open(&gb_repository, session).unwrap();
let deltas_reader = deltas::Reader::new(&session_reader);
let deltas_by_filepath = deltas_reader.read(&None).unwrap();
let deltas_by_filepath = deltas_reader.read(None).unwrap();
for deltas in deltas_by_filepath.values() {
for delta in deltas {
delta.operations.iter().for_each(|operation| {
@ -582,7 +582,7 @@ mod test {
let reader =
sessions::Reader::open(&gb_repository, sessions_slice.first().unwrap()).unwrap();
let files = reader.files(&None).unwrap();
let files = reader.files(None).unwrap();
if i == 0 {
assert_eq!(files.len(), 0);
@ -656,7 +656,7 @@ mod test {
for session in &mut *sessions_slice {
let session_reader = sessions::Reader::open(&gb_repository, session).unwrap();
let deltas_reader = deltas::Reader::new(&session_reader);
let deltas_by_filepath = deltas_reader.read(&None).unwrap();
let deltas_by_filepath = deltas_reader.read(None).unwrap();
for deltas in deltas_by_filepath.values() {
for delta in deltas {
delta.operations.iter().for_each(|operation| {
@ -668,7 +668,7 @@ mod test {
let reader =
sessions::Reader::open(&gb_repository, sessions_slice.first().unwrap()).unwrap();
let files = reader.files(&None).unwrap();
let files = reader.files(None).unwrap();
if i == 0 {
assert_eq!(files.len(), 0);
@ -719,7 +719,7 @@ mod test {
let session = gb_repository.get_current_session()?.unwrap();
let session_reader = sessions::Reader::open(&gb_repository, &session).unwrap();
let deltas_reader = deltas::Reader::new(&session_reader);
let deltas_by_filepath = deltas_reader.read(&None).unwrap();
let deltas_by_filepath = deltas_reader.read(None).unwrap();
for deltas in deltas_by_filepath.values() {
for delta in deltas {
delta.operations.iter().for_each(|operation| {
@ -729,7 +729,7 @@ mod test {
}
let reader = sessions::Reader::open(&gb_repository, &session).unwrap();
let files = reader.files(&None).unwrap();
let files = reader.files(None).unwrap();
let base_file = files.get(&relative_file_path.to_path_buf());
let mut text: Vec<char> = match base_file {