Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Conversation

bwarden
Copy link
Contributor

@bwarden bwarden commented Apr 23, 2025

When downloading cacheable files from the upstream mirror, swupd fails to write the local cached copy because it doesn't create the directories before attempting to write the files, for example:
/var/lib/swupd/cache/https___download.clearlinux.org_update/download/latest

Add a mkdir -p call to create those intermediate directories in the intended cache file path.

Failure signature:

$ sudo swupd check-update --debug -u https://download.clearlinux.org/update
Warning: Overriding version and content URLs with https://download.clearlinux.org/update
2025-04-23 10:35:19 (src/swupd_lib/curl.c:206)    Debug: Initializing swupd curl library
2025-04-23 10:35:19 (src/swupd_lib/curl.c:141)    Debug: Curl - check_connection url: https://download.clearlinux.org/update/version/latest_version
2025-04-23 10:35:19 (src/swupd_lib/curl.c:605)    Debug: Curl - Start sync download: https://download.clearlinux.org/update/version/latest_version -> <memory>
2025-04-23 10:35:19 (src/swupd_lib/curl.c:440)    Debug: Curl - process_curl_error_codes: curl_ret = 0, response = 200
2025-04-23 10:35:19 (src/swupd_lib/curl.c:623)    Debug: Curl - Complete sync download: https://download.clearlinux.org/update/version/latest_version -> <memory>, status=0
2025-04-23 10:35:19 (src/swupd_lib/progress.c:53)
2025-04-23 10:35:19 (src/swupd_lib/curl.c:605)    Debug: Curl - Start sync download: https://download.clearlinux.org/update/version/latest_version.sig -> <memory>
2025-04-23 10:35:19 (src/swupd_lib/curl.c:440)    Debug: Curl - process_curl_error_codes: curl_ret = 0, response = 200
2025-04-23 10:35:19 (src/swupd_lib/curl.c:623)    Debug: Curl - Complete sync download: https://download.clearlinux.org/update/version/latest_version.sig -> <memory>, status=0
2025-04-23 10:35:19 (src/swupd_lib/progress.c:53)
2025-04-23 10:35:19 (src/swupd_lib/curl.c:605)    Debug: Curl - Start sync download: https://download.clearlinux.org/update/43290/format -> <memory>
2025-04-23 10:35:19 (src/swupd_lib/curl.c:440)    Debug: Curl - process_curl_error_codes: curl_ret = 0, response = 200
2025-04-23 10:35:19 (src/swupd_lib/curl.c:623)    Debug: Curl - Complete sync download: https://download.clearlinux.org/update/43290/format -> <memory>, status=0
2025-04-23 10:35:19 (src/swupd_lib/progress.c:53)
2025-04-23 10:35:19 (src/swupd_lib/curl.c:385)    Error: Curl - Cannot open file '/var/lib/swupd/cache/https___download.clearlinux.org_update/download/latest' for writing - 'No such file or directory'
2025-04-23 10:35:19 (src/swupd_lib/curl.c:471)    Debug: Curl - process_curl_error_codes: curl_ret = 23, response = 0
2025-04-23 10:35:19 (src/swupd_lib/curl.c:483)    Debug: Curl - Download failed: response (0) -  ''
2025-04-23 10:35:19 (src/swupd_lib/curl.c:486)    Debug: Curl - process_curl_error_codes - curl_ret = 23
2025-04-23 10:35:19 (src/swupd_lib/curl.c:506)    Error: Curl - Error downloading to local file - ''
2025-04-23 10:35:19 (src/swupd_lib/curl.c:507)    Error: Curl - Check free space for /var/lib/swupd?
2025-04-23 10:35:19 (src/swupd_lib/curl.c:623)    Debug: Curl - Complete sync download: https://download.clearlinux.org/update/version/format41/latest -> /var/lib/swupd/cache/https___download.clearlinux.org_update/download/latest, status=6
2025-04-23 10:35:19 (src/swupd_lib/progress.c:53)

@bwarden
Copy link
Contributor Author

bwarden commented Apr 23, 2025

Embedded tests disfavor calling dirname() outside of sys.*:

not ok 1 ANL004: Functions to avoid
# (in test file test/code_analysis/warning_functions.bats, line 44)
#   `[ "$error" -eq "0" ]' failed
# Found dirname on files:
# src/swupd_lib/curl.c:	mkdir_p(dirname(strdupa(file->path)));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant