mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-10-26 13:12:25 +03:00
update session lastTs before flushing
This commit is contained in:
parent
c880a68408
commit
32329ecb81
@ -10,7 +10,7 @@ use std::{
|
||||
io::{BufReader, Read},
|
||||
os::unix::prelude::MetadataExt,
|
||||
path::Path,
|
||||
time::SystemTime,
|
||||
time,
|
||||
};
|
||||
use uuid::Uuid;
|
||||
|
||||
@ -105,8 +105,8 @@ impl Session {
|
||||
}
|
||||
|
||||
pub fn from_head(repo: &git2::Repository, project: &projects::Project) -> Result<Self> {
|
||||
let now_ts = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
let now_ts = time::SystemTime::now()
|
||||
.duration_since(time::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis();
|
||||
|
||||
@ -202,7 +202,7 @@ impl Session {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn update(&self, project: &projects::Project) -> Result<()> {
|
||||
pub fn update(&mut self, project: &projects::Project) -> Result<()> {
|
||||
update(project, self)
|
||||
}
|
||||
|
||||
@ -277,7 +277,12 @@ fn write(session_path: &Path, session: &Session) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update(project: &projects::Project, session: &Session) -> Result<()> {
|
||||
fn update(project: &projects::Project, session: &mut Session) -> Result<()> {
|
||||
session.meta.last_timestamp_ms = time::SystemTime::now()
|
||||
.duration_since(time::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis();
|
||||
|
||||
let session_path = project.session_path();
|
||||
log::debug!("{}: Updating current session", session_path.display());
|
||||
if session_path.exists() {
|
||||
@ -453,6 +458,10 @@ fn flush(
|
||||
));
|
||||
}
|
||||
|
||||
session
|
||||
.update(project)
|
||||
.with_context(|| format!("failed to update session"))?;
|
||||
|
||||
let wd_index = &mut git2::Index::new()
|
||||
.with_context(|| format!("failed to create index for working directory"))?;
|
||||
build_wd_index(&repo, wd_index).with_context(|| format!("failed to build wd index"))?;
|
||||
|
@ -8,7 +8,6 @@ use std::fs;
|
||||
use std::path::Path;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::thread;
|
||||
use std::time::SystemTime;
|
||||
use std::{collections::HashMap, sync::Mutex};
|
||||
|
||||
#[derive(Default)]
|
||||
@ -234,11 +233,6 @@ fn write_beginning_meta_files<R: tauri::Runtime>(
|
||||
.map_err(|e| format!("Error while getting current session: {}", e.to_string()))?
|
||||
{
|
||||
Some(mut session) => {
|
||||
let now_ts = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis();
|
||||
session.meta.last_timestamp_ms = now_ts;
|
||||
session
|
||||
.update(project)
|
||||
.with_context(|| "failed to update session")?;
|
||||
|
@ -129,7 +129,6 @@ fn session_to_commit(
|
||||
let elapsed_last = now - current_session.meta.last_timestamp_ms;
|
||||
let elapsed_start = now - current_session.meta.start_timestamp_ms;
|
||||
|
||||
// TODO: uncomment
|
||||
if (elapsed_last > FIVE_MINUTES) || (elapsed_start > ONE_HOUR) {
|
||||
Ok(Some(current_session))
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user