kworkflow / patch-hub

patch-hub is a TUI that streamlines the interaction of Linux developers with patches archived on lore.kernel.org
GNU General Public License v2.0
7 stars 6 forks source link

Cache dir isn't being created before use #21

Closed davidbtadokoro closed 2 months ago

davidbtadokoro commented 2 months ago

Description:

Currently, the use of the cache directory for patch-hub, which is located at ${KW_CACHE_DIR}/patch_hub or ${HOME}/.cache/kw/patch_hub is used for patchsets downloaded using the b4 tool as introduced by commit 51f39380.

However, we don't't check if the path to this cache directory exists before using it. This causes a crash when entering a "Patchset Details and Actions" screen, as it needs the downloaded patchset by b4, which fails due to the path to the cache directory not existing.

This flew under the radar because, for some reason, Arch-based distros (and Fedora-based as well) seem to create nonexistent parent directories in a path. As I use Arch (btw), I didn't notice this, but one user mentioned this error on a Debian system and the issue re-surfaced when testing the releases in a Debian container.

Edit: After some digging, I found that the b4 tool creates intermediary directories when using a custom path output (the case), and that the difference in the distros is how b4 behaves in this manner.

How to reproduce:

  1. Create a container instance based on a Debian image and start a Bash session with
    docker run -it debian:latest bash
  2. Install curl, xz-utils, and b4 with
    apt update && apt install curl xz-utils b4
  3. Download the v0.1.1 release of patch-hub and decompress with
    curl -LO https://github.com/kworkflow/patch-hub/releases/download/v0.1.1/patch-hub-x86_64-unknown-linux-gnu.tar.xz
    tar -xvf patch-hub-x86_64-unknown-linux-gnu.tar.xz
  4. Run patch-hub, consult a mailing list, and try opening a patchset to see the crash occur.

Expected behavior:

We should try to create the cache every time we use it.

Screenshots

2024-08-09-005638_1894x1028_scrot

Setup:

Screenshot setup: Docker-Hub debian:latest image - digest 8dd517b3c9f Release version: version 0.1.1