@@ -287,11 +287,21 @@ impl ExecutionContext<'_> {
287287 } ;
288288
289289 // 5. Update cache if successful and determine cache update status
290+ // Priority: NonZeroExitStatus > ReceivedCtrlC > StdinDataExists > Success
290291 let cache_update_status = if let Some ( ( track_result, cache_metadata) ) =
291292 track_result_with_cache_metadata
292293 {
293- if result. exit_status . success ( ) {
294- // Execution succeeded, attempt cache update
294+ if !result. exit_status . success ( ) {
295+ // Priority 1: Non-zero exit status - don't update cache
296+ CacheUpdateStatus :: NotUpdated ( CacheNotUpdatedReason :: NonZeroExitStatus )
297+ } else if result. received_ctrl_c {
298+ // Priority 2: Received Ctrl+C - execution was interrupted, unsafe to cache
299+ CacheUpdateStatus :: NotUpdated ( CacheNotUpdatedReason :: ReceivedCtrlC )
300+ } else if result. stdin_had_data {
301+ // Priority 3: Stdin had data - output may depend on input, unsafe to cache
302+ CacheUpdateStatus :: NotUpdated ( CacheNotUpdatedReason :: StdinDataExists )
303+ } else {
304+ // Success: attempt cache update
295305 let fingerprint_ignores =
296306 cache_metadata. spawn_fingerprint . fingerprint_ignores ( ) . map ( |v| v. as_slice ( ) ) ;
297307 match PostRunFingerprint :: create (
@@ -326,9 +336,6 @@ impl ExecutionContext<'_> {
326336 return Err ( ExecutionAborted ) ;
327337 }
328338 }
329- } else {
330- // Execution failed with non-zero exit status, don't update cache
331- CacheUpdateStatus :: NotUpdated ( CacheNotUpdatedReason :: NonZeroExitStatus )
332339 }
333340 } else {
334341 // Caching was disabled for this task
0 commit comments