Skip to content

Commit 807d0a5

Browse files
committed
Target go-IPFS 0.5 – 0.8 and drop 0.4.x compatiblity code
1 parent 0a460f6 commit 807d0a5

File tree

7 files changed

+27
-52
lines changed

7 files changed

+27
-52
lines changed

.travis.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ before_install:
5151
### ==== MODIFY THIS WHEN CHANGING TARGET OR MINIMUM IPFS VERSION ==== ###
5252
case "${IPFS_VERSION:-latest}" in
5353
latest) # Currently targeted version
54-
VERSION=0.7.0
55-
SHA512_LINUX=1d5910f27e8d7ea333145f15c6edcbacc1e8db3a99365f0847467bdfa7c73f4d7a05562e46be8e932056c8324ed0769ca1b6758dfb0ac4c2e1b6066b57c4a086
56-
SHA512_DARWIN=d864b58e832ce49df7ef77c8012ce9e6e7585f693c03ba8e4ebf86f772eebf0d6a00dde279cdc0f16250ad20bac6f67db6b3966848c3e3bcbdc4b4d2dee1cd89
57-
SHA512_WINDOWS=2262220e0502f00d6d429cfd16d2f0c55fa73cafb100bd72589fd1f7d97b3527dc7d49d60460650796d754f2aa4b03ba07753457691ef7d1a10d10857b819045
54+
VERSION=0.8.0
55+
SHA512_LINUX=64d5464e5b8636c4e4d76a285350de23e77b03199037fc79e4a6ed65569788586af6993b7faa0a826a2b5ffca3795e67c0c10386f98d1be1842d9c284d3fcf07
56+
SHA512_DARWIN=38d2196c7bfde43661c323c862928eb183f75d9879550f2c0eafb2b9db0bdf1b577d3bb5a201b2287c4e753628affbbbb90d37d0f9d197d00256ebefb2ff7203
57+
SHA512_WINDOWS=f9e260ea039c4d263fd5ef9d6d9829b98f88d524a206985169a89549fdb46b329d2fee2ac3196885726781dae247dd1fed00a9dba3d4ddd86a6423f2374b2276
5858
;;
5959
compat) # Earliest supported version
60-
VERSION=0.4.23
61-
SHA512_LINUX=5eebebd4d4628a01c3b6615d96123a5c744f64da18fc0950e00d99a36abb02eee694c1bb67549341a645ebb99f30de9198c33b556cdee2609013409a510d1d2b
60+
VERSION=0.5.0
61+
SHA512_LINUX=583ea6920226cf47cc3a2856a1f87273df9a5150b9f7e765280eec4b2d438f7e0a8b60a7283a3567b86165085b9b8b49ee867dffa83234c8cc46055d7ab98d90
6262
;;
6363
esac
6464
### ------------------------------ END ------------------------------- ###

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ py-ipfs-http-client 0.X.X (XX.XX.20XX)
33

44
* (None yet)
55

6+
py-ipfs-http-client 0.8.0 (XX.XX.20XX)
7+
--------------------------------------
8+
9+
* py-ipfs-api-client will now only warn when detecting an unsupported daemon version
10+
* Rationale: During the 0.4.x series the library required many changes to stay compatible
11+
with the respective daemon version, but since 0.5.0 appears to be no longer the case
12+
* Compatiblity bumped to go-IPFS 0.8.x (by Jan Rydzewski and other community members bugging me)
13+
14+
**Breaking changes in this release**:
15+
16+
* Dropped support for the (previously deprecated) `return_result` parameter of `.repo.gc(…)`
17+
618
py-ipfs-http-client 0.7.0 (15.03.2021)
719
--------------------------------------
820

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ See the [relevant section of the CHANGELOG](CHANGELOG.md#py-ipfs-http-client-041
1616
unmaintained and does not work with any recent go-IPFS version.
1717

1818
**Note**: This library occasionally has to change to stay compatible with the IPFS HTTP API.
19-
Currently, this library is tested against [go-ipfs v0.7.0](https://github.com/ipfs/go-ipfs/releases/tag/v0.7.0).
20-
We strive to support the last 5 releases of go-IPFS at any given time; go-IPFS v0.4.23 therefore
19+
Currently, this library is tested against [go-ipfs v0.8.0](https://github.com/ipfs/go-ipfs/releases/tag/v0.8.0).
20+
We strive to support the last 5 releases of go-IPFS at any given time; go-IPFS v0.5.0 therefore
2121
being to oldest supported version at this time.
2222

2323
## Table of Contents

ipfshttpclient/client/__init__.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
DEFAULT_ADDR = multiaddr.Multiaddr(os.environ.get("PY_IPFS_HTTP_CLIENT_DEFAULT_ADDR", '/dns/localhost/tcp/5001/http'))
1515
DEFAULT_BASE = str(os.environ.get("PY_IPFS_HTTP_CLIENT_DEFAULT_BASE", 'api/v0'))
1616

17-
VERSION_MINIMUM = "0.4.23"
17+
# This range inclusive-exclusive, so the daemon version must match
18+
# `VERSION_MINIMUM <= version < VERSION_MAXIMUM`
19+
# for it to be considered compatible.
20+
VERSION_MINIMUM = "0.5.0"
1821
VERSION_BLACKLIST = []
19-
VERSION_MAXIMUM = "0.8.0"
22+
VERSION_MAXIMUM = "0.9.0"
2023

2124
from . import bitswap
2225
from . import block
@@ -229,11 +232,6 @@ def apply_workarounds(self):
229232
version = tuple(map(int, version_info["Version"].split('-', 1)[0].split('.')))
230233

231234
self._workarounds.clear()
232-
if version < (0, 5): # pragma: no cover (workaround)
233-
# Not really a workaround, but make use of HEAD requests on versions
234-
# that support them to speed things up if we are not interested in the
235-
# response anyways
236-
self._workarounds.add("use_http_head_for_no_result")
237235

238236
return version_info
239237

ipfshttpclient/client/repo.py

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import warnings
2-
31
from . import base
42

53

64
class Section(base.SectionBase):
75
@base.returns_multiple_items(base.ResponseBase)
8-
def gc(self, *, quiet: bool = False, return_result: bool = True, **kwargs: base.CommonArgs):
6+
def gc(self, *, quiet: bool = False, **kwargs: base.CommonArgs):
97
"""Removes stored objects that are not pinned from the repo
108
119
.. code-block:: python
@@ -30,27 +28,13 @@ def gc(self, *, quiet: bool = False, return_result: bool = True, **kwargs: base.
3028
Passing ``True`` to this parameter often causing the GC process to
3129
speed up tremendously as it will also avoid generating the list of
3230
removed objects in the connected daemon at all.
33-
return_result
34-
If ``False`` this is a legacy alias for ``quiet=True``.
35-
36-
(Will be dropped in py-ipfs-api-client 0.7.x!)
3731
3832
Returns
3933
-------
4034
dict
4135
List of IPFS objects that have been removed
4236
"""
43-
if not return_result:
44-
warnings.warn("Parameter `return_result` of `.repo.gc(…)` is deprecated "
45-
"in favour of the newer `quiet` parameter", DeprecationWarning)
46-
47-
quiet = quiet or not return_result
48-
49-
if "use_http_head_for_no_result" not in self._client.workarounds:
50-
# go-ipfs 0.4.22- does not support the quiet option yet
51-
kwargs.setdefault("opts", {})["quiet"] = quiet
52-
53-
kwargs.setdefault("return_result", not quiet)
37+
kwargs.setdefault("opts", {})["quiet"] = quiet
5438

5539
return self._client.request('/repo/gc', decoder='json', **kwargs)
5640

ipfshttpclient/http_common.py

-4
Original file line numberDiff line numberDiff line change
@@ -605,11 +605,7 @@ def request( # type: ignore[misc]
605605
if not return_result:
606606
decoder = "none"
607607

608-
# HTTP method must always be "POST" since go-IPFS 0.5
609608
method = "POST"
610-
if "use_http_head_for_no_result" in self.workarounds and not return_result: # pragma: no cover
611-
method = "HEAD"
612-
613609
parser = encoding.get_encoding(decoder)
614610

615611
closables, res = self._request(

test/functional/test_repo.py

-15
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,3 @@ def test_gc(client):
2121
assert orig_objs > cur_objs
2222
keys = [el["Key"]["/"] for el in gc]
2323
assert garbage in keys
24-
25-
26-
def test_gc_no_result(client):
27-
# Add and unpin an object to be garbage collected
28-
garbage = client.add_str("Test String")
29-
client.pin.rm(garbage)
30-
31-
# Collect the garbage object with object count before and after
32-
orig_objs = client.repo.stat()["NumObjects"]
33-
gc = client.repo.gc(quiet=True)
34-
cur_objs = client.repo.stat()["NumObjects"]
35-
36-
# Verify the garbage object was collected
37-
assert orig_objs > cur_objs
38-
assert gc is None

0 commit comments

Comments
 (0)