Corrige sessões duplicadas ao reabrir uma sessão recente
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
627eae1b8b
commit
b1ac320193
2 files changed
+21
-4
No files matched your search
+10
-4
@@ -215,8 +215,11 @@ async function openRecent(r) {
|
||||
try {
|
||||
const { job } = await rpc('session_load', { path: r.path });
|
||||
const st = await rpc('status', { job });
|
||||
const s = { job, target: st.target, label: 'Sessão: ' + st.target.split(/[\\/]/).pop() };
|
||||
S.sessions.unshift(s);
|
||||
let s = S.sessions.find((x) => x.job === job);
|
||||
if (!s) {
|
||||
s = { job, target: st.target, label: 'Sessão: ' + st.target.split(/[\\/]/).pop() };
|
||||
S.sessions.unshift(s);
|
||||
}
|
||||
openJob(s);
|
||||
} catch (e) { info({ title: 'Não foi possível abrir a sessão', html: `<p>${esc(e.message)}</p>` }); }
|
||||
}
|
||||
@@ -246,8 +249,11 @@ $('#loadSessionBtn').onclick = async () => {
|
||||
try {
|
||||
const { job } = await rpc('session_load', { path });
|
||||
const st = await rpc('status', { job });
|
||||
const s = { job, target: st.target, label: 'Sessão: ' + st.target.split(/[\\/]/).pop() };
|
||||
S.sessions.unshift(s);
|
||||
let s = S.sessions.find((x) => x.job === job);
|
||||
if (!s) {
|
||||
s = { job, target: st.target, label: 'Sessão: ' + st.target.split(/[\\/]/).pop() };
|
||||
S.sessions.unshift(s);
|
||||
}
|
||||
openJob(s);
|
||||
} catch (e) { info({ title: 'Não foi possível abrir a sessão', html: `<p>${esc(e.message)}</p>` }); }
|
||||
};
|
||||
|
||||
@@ -721,6 +721,17 @@ impl Engine {
|
||||
}
|
||||
|
||||
pub fn load_session(&self, path: &str) -> Result<String> {
|
||||
// Clicar de novo numa sessão já aberta reaproveita o job em vez de criar outro igual.
|
||||
let want = Path::new(path);
|
||||
if let Some(j) = self
|
||||
.jobs
|
||||
.lock()
|
||||
.unwrap()
|
||||
.values()
|
||||
.find(|j| j.session_file.lock().unwrap().as_deref() == Some(want))
|
||||
{
|
||||
return Ok(j.id.clone());
|
||||
}
|
||||
let bytes = std::fs::read(path).map_err(|e| {
|
||||
if e.kind() == std::io::ErrorKind::PermissionDenied {
|
||||
Error::msg(format!(
|
||||
|
||||
Reference in new issue
Block a user