Skip to content

Commit

Permalink
fix infinite loop update checker in a specific condition
Browse files Browse the repository at this point in the history
close issue #1527
  • Loading branch information
Ousret committed Apr 4, 2024
1 parent c859191 commit fb54d2b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- Removed support for keeping the original casing of HTTP headers. This come from an outer constraint by newer protocols, namely HTTP/2+ that normalize header keys by default.
From the HTTPie user perspective, they are "prettified" on the output by default. e.g. "x-hello-world" is displayed as "X-Hello-World".
- Fixed multipart form data having filename not rfc2231 compliant when name contain non-ascii characters. ([#1401](https://github.com/httpie/cli/issues/1401))
- Fixed issue where the configuration directory was not created at runtime that made the update fetcher run everytime. ([#1527](https://github.com/httpie/cli/issues/1527))

The plugins are expected to work without any changes. The only caveat would be that certain plugin explicitly require `requests`.
Future contributions may be made in order to relax the constraints where applicable.
Expand Down
4 changes: 4 additions & 0 deletions httpie/config.py
Expand Up @@ -143,6 +143,10 @@ class Config(BaseConfigDict):
def __init__(self, directory: Union[str, Path] = DEFAULT_CONFIG_DIR):
self.directory = Path(directory)
super().__init__(path=self.directory / self.FILENAME)
# this one ensure we do not init HTTPie without the proper config directory
# there's an issue where the fetch_update daemon run without having the directory present. that induce a
# loop trying to fetch latest versions information.
self.ensure_directory()
self.update(self.DEFAULTS)

@property
Expand Down
15 changes: 15 additions & 0 deletions tests/test_config.py
@@ -1,3 +1,4 @@
import os.path
from pathlib import Path

import pytest
Expand All @@ -23,6 +24,20 @@ def test_default_options(httpbin):
}


def test_config_dir_is_created():
dir_path = str(get_default_config_dir()) + "--fake"

try:
os.rmdir(dir_path)
except FileNotFoundError:
pass

assert not os.path.exists(dir_path)
Config(dir_path)
assert os.path.exists(dir_path)
os.rmdir(dir_path)


def test_config_file_not_valid(httpbin):
env = MockEnvironment()
env.create_temp_config_dir()
Expand Down

0 comments on commit fb54d2b

Please sign in to comment.