Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Fix can’t unlink: part_ no such directory #1927

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ def cleanup(self):
part_ct = 0
for path in self.download_cache.glob("part_*"):
path = Path(path)
path = self.download_cache // path.name
ch.VERBOSE("deleting: %s" % path)
path.unlink()
part_ct += 1
Expand Down
30 changes: 30 additions & 0 deletions test/build/40_pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,33 @@ EOF
[[ $status -eq 1 ]]
[[ $output = *'registry-1.docker.io:443/charliecloud/metadata:doesnotexist'* ]]
}

@test 'remove part_ files' {
export CH_IMAGE_STORAGE=/var/tmp/tmpdir
ch-image pull alpine

# create directory
mkdir -p /var/tmp/tmpdir/dlcache

# create a part_ file
touch /var/tmp/tmpdir/dlcache/part_PROBLEM

# list images to invoke error
set +e
out=$(ch-image list 2>&1)
retcode=$?
set -e

echo "--- return code: ${retcode}"
echo '--- output:'
echo "$out"

# clean up the directory
rm -rf /var/tmp/tmpdir

# check if output errors
if [[ $retcode -ne 0 ]]; then
echo "fail: part_ file wasn't cleaned properly."
exit 1
fi
}
Loading