Fix ls error when no tar files exist in cache restore#170
Merged
Conversation
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
Copilot
AI
changed the title
[WIP]
Fix ls error when no tar files exist in cache restore
Sep 30, 2025
cannot access '/home/runner/cache-apt-pkgs/*.tar': No such file or directory
awalsh128
approved these changes
Sep 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an issue where
restore_pkgs.shwould fail with "No such file or directory" error when attempting to restore cached packages but no.tarfiles were present in the cache directory.Problem
The issue occurred on line 43 of
restore_pkgs.sh:cached_filepaths=$(ls -1 "${cache_dir}"/*.tar | sort)When a cache hit occurred but no actual package
.tarfiles existed (only manifest files and other metadata), thelscommand would fail with:This scenario can happen in cases where:
Solution
Added stderr redirection to gracefully handle missing
.tarfiles:cached_filepaths=$(ls -1 "${cache_dir}"/*.tar 2>/dev/null | sort)Now when no
.tarfiles exist:cached_filepathsbecomes emptyTesting
Verified the fix works correctly in multiple scenarios:
.tarfiles: gracefully reports 0 packages restored.tarfiles: works normally as beforeThis is a minimal, surgical fix that preserves all existing functionality while resolving the error condition that was causing the action to fail silently.
Closes #[issue_number] (related to issues #110 and #116)
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.