Skip to content

Commit 2632a45

Browse files
authored
Turbopack: fix unhelpful error message when deleting folder fails (#81718)
### What? Fixes the unhelpful error message: ``` [Error: No such file or directory (os error 2)] { code: 'GenericFailure' } ```
1 parent d568550 commit 2632a45

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

turbopack/crates/turbo-tasks-backend/src/database/db_versioning.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,11 @@ pub fn handle_db_versioning(
143143
}
144144
} else {
145145
path = base_path.join("temp");
146-
// propagate errors: if this fails we may have stale files left over in the temp directory
147-
remove_dir_all(&path)?;
146+
if path.exists() {
147+
// propagate errors: if this fails we may have stale files left over in the temp
148+
// directory
149+
remove_dir_all(&path)?;
150+
}
148151
}
149152

150153
Ok(path)

turbopack/crates/turbo-tasks-backend/src/kv_backing_storage.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,11 @@ impl<T: KeyValueDatabase> KeyValueDatabaseBackingStorage<T> {
166166
where
167167
T: Send + Sync + 'static,
168168
{
169-
let startup_cache_state = check_db_invalidation_and_cleanup(&base_path)?;
170-
let versioned_path = handle_db_versioning(&base_path, version_info, is_ci)?;
171-
let database = (database)(versioned_path)?;
169+
let startup_cache_state = check_db_invalidation_and_cleanup(&base_path)
170+
.context("Failed to check database invalidation and cleanup")?;
171+
let versioned_path = handle_db_versioning(&base_path, version_info, is_ci)
172+
.context("Failed to handle database versioning")?;
173+
let database = (database)(versioned_path).context("Failed to open database")?;
172174
let backing_storage = Self {
173175
inner: Arc::new_cyclic(
174176
move |weak_inner: &Weak<KeyValueDatabaseBackingStorageInner<T>>| {

0 commit comments

Comments
 (0)