Skip to content

Commit

Permalink
Don't try and garbage collect tempfiles (Cherry-pick of #19103) (#19113)
Browse files Browse the repository at this point in the history
Fixes #19007 by giving temp files an extension and checking when
collecting fingerprints

Co-authored-by: Joshua Cannon <joshdcannon@gmail.com>
  • Loading branch information
WorkerPants and thejcannon authored May 26, 2023
1 parent 956c8aa commit 1abb154
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/rust/engine/fs/store/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use parking_lot::Mutex;
use sharded_lmdb::ShardedLmdb;
use std::os::unix::fs::PermissionsExt;
use task_executor::Executor;
use tempfile::NamedTempFile;
use tempfile::Builder;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWriteExt};
use workunit_store::ObservationMetric;

Expand Down Expand Up @@ -230,7 +230,9 @@ impl ShardedFSDB {
.executor
.spawn_blocking(
move || {
NamedTempFile::new_in(dest_path2.parent().unwrap())
Builder::new()
.suffix(".tmp")
.tempfile_in(dest_path2.parent().unwrap())
.map_err(|e| format!("Failed to create temp file: {e}"))
},
|e| Err(format!("temp file creation task failed: {e}")),
Expand Down Expand Up @@ -425,6 +427,10 @@ impl UnderlyingByteStore for ShardedFSDB {
format!("Error iterating dir {:?}: {e}", shard.path().file_name())
})?;
let path = large_file.path();
if path.extension().is_some() {
continue; // NB: This is a tempfile
}

let hash = path.file_name().unwrap().to_str().unwrap();
let (length, mtime) = large_file
.metadata()
Expand Down

0 comments on commit 1abb154

Please sign in to comment.