[feat] ensure cleanup of .last_model file between and after runs

This commit is contained in:
2025-08-08 09:21:04 +02:00
parent f991a47b5b
commit 02c15ba27a
2 changed files with 19 additions and 9 deletions

11
TODO.md
View File

@@ -1,26 +1,19 @@
- [x] update the project to no more use features
- update last_model to be only used during one run
- [x] update last_model to be only used during one run
- rename project to "PolyScribe"
- add tests
- update local models using hashes (--update-models)
- create folder models/ if not present -> use /usr/share/polyscribe/models/ for release version, use ./models/ for development version
- create missing folders for output files
- for merging (command line flag) -> if not present, treat each file as separate output (--merge | -m)
- for merge + separate output -> if present, treat each file as separate output and also output a merged version (--merge-and-separate)
- set speaker-names per input-file -> prompt user for each file if flag is set (--set-speaker-names)
- fix cli output for model display
- refactor into proper cli app
- add support for video files -> use ffmpeg to extract audio
- detect gpus and use them
- add error handling
- add tests
- add verbose flag (--verbose | -v) + add logging
- add documentation
- package into executable
- add CI

View File

@@ -334,9 +334,26 @@ fn transcribe_native(audio_path: &Path, speaker: &str, lang_opt: Option<&str>) -
Ok(items)
}
struct LastModelCleanup {
path: PathBuf,
}
impl Drop for LastModelCleanup {
fn drop(&mut self) {
let _ = std::fs::remove_file(&self.path);
}
}
fn main() -> Result<()> {
let args = Args::parse();
// Remove stale last_model from previous runs and set up cleanup on exit
let models_dir = Path::new("models");
let last_model_path = models_dir.join(".last_model");
// Best-effort cleanup at start
let _ = std::fs::remove_file(&last_model_path);
// Ensure cleanup at end of program, regardless of exit path
let _last_model_cleanup = LastModelCleanup { path: last_model_path.clone() };
// If requested, run the interactive model downloader first. If no inputs were provided, exit after downloading.
if args.download_models {
if let Err(e) = models::run_interactive_model_downloader() {