Skip to content

Commit d7713bf

Browse files
committed
frontend/latex: fix sagetex vs. clean issue -- #8680
1 parent 2d22120 commit d7713bf

File tree

1 file changed

+12
-4
lines changed
  • src/packages/frontend/frame-editors/latex-editor

1 file changed

+12
-4
lines changed

src/packages/frontend/frame-editors/latex-editor/sagetex.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
2+
* This file is part of CoCalc: Copyright © 2020-2025 Sagemath, Inc.
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

@@ -33,18 +33,26 @@ export async function sagetex_hash(
3333
const { base, directory } = parse_path(path); // base, directory, filename
3434
const s = sagetex_file(base);
3535
status(`sha1sum ${s}`);
36+
37+
// Check if file exists and compute hash only if it does; otherwise return unique value
3638
const output = await exec(
3739
{
3840
timeout: 10,
39-
command: "sha1sum",
40-
args: [s],
41+
command: `test -f '${s}' && sha1sum '${s}' || true`,
42+
bash: true,
4143
project_id: project_id,
4244
path: output_directory || directory,
43-
err_on_exit: true,
45+
err_on_exit: false,
4446
aggregate: time,
4547
},
4648
path,
4749
);
50+
51+
// If file doesn't exist, return unique timestamp-based value to ensure rebuild
52+
if (!output.stdout.trim()) {
53+
return `missing-${Date.now()}`;
54+
}
55+
4856
return output.stdout.split(" ")[0];
4957
}
5058

0 commit comments

Comments
 (0)