Target go-IPFS 0.5 – 0.8 and drop 0.4.x compatiblity code

This commit is contained in:
Alexander Schlarb
2021-04-09 23:30:46 +02:00
committed by Alexander Schlarb
parent 0a460f6e26
commit 807d0a5f50
7 changed files with 27 additions and 52 deletions

View File

@@ -51,14 +51,14 @@ before_install:
### ==== MODIFY THIS WHEN CHANGING TARGET OR MINIMUM IPFS VERSION ==== ###
case "${IPFS_VERSION:-latest}" in
latest) # Currently targeted version
VERSION=0.7.0
SHA512_LINUX=1d5910f27e8d7ea333145f15c6edcbacc1e8db3a99365f0847467bdfa7c73f4d7a05562e46be8e932056c8324ed0769ca1b6758dfb0ac4c2e1b6066b57c4a086
SHA512_DARWIN=d864b58e832ce49df7ef77c8012ce9e6e7585f693c03ba8e4ebf86f772eebf0d6a00dde279cdc0f16250ad20bac6f67db6b3966848c3e3bcbdc4b4d2dee1cd89
SHA512_WINDOWS=2262220e0502f00d6d429cfd16d2f0c55fa73cafb100bd72589fd1f7d97b3527dc7d49d60460650796d754f2aa4b03ba07753457691ef7d1a10d10857b819045
VERSION=0.8.0
SHA512_LINUX=64d5464e5b8636c4e4d76a285350de23e77b03199037fc79e4a6ed65569788586af6993b7faa0a826a2b5ffca3795e67c0c10386f98d1be1842d9c284d3fcf07
SHA512_DARWIN=38d2196c7bfde43661c323c862928eb183f75d9879550f2c0eafb2b9db0bdf1b577d3bb5a201b2287c4e753628affbbbb90d37d0f9d197d00256ebefb2ff7203
SHA512_WINDOWS=f9e260ea039c4d263fd5ef9d6d9829b98f88d524a206985169a89549fdb46b329d2fee2ac3196885726781dae247dd1fed00a9dba3d4ddd86a6423f2374b2276
;;
compat) # Earliest supported version
VERSION=0.4.23
SHA512_LINUX=5eebebd4d4628a01c3b6615d96123a5c744f64da18fc0950e00d99a36abb02eee694c1bb67549341a645ebb99f30de9198c33b556cdee2609013409a510d1d2b
VERSION=0.5.0
SHA512_LINUX=583ea6920226cf47cc3a2856a1f87273df9a5150b9f7e765280eec4b2d438f7e0a8b60a7283a3567b86165085b9b8b49ee867dffa83234c8cc46055d7ab98d90
;;
esac
### ------------------------------ END ------------------------------- ###

View File

@@ -3,6 +3,18 @@ py-ipfs-http-client 0.X.X (XX.XX.20XX)
* (None yet)
py-ipfs-http-client 0.8.0 (XX.XX.20XX)
--------------------------------------
* py-ipfs-api-client will now only warn when detecting an unsupported daemon version
* Rationale: During the 0.4.x series the library required many changes to stay compatible
with the respective daemon version, but since 0.5.0 appears to be no longer the case
* Compatiblity bumped to go-IPFS 0.8.x (by Jan Rydzewski and other community members bugging me)
**Breaking changes in this release**:
* Dropped support for the (previously deprecated) `return_result` parameter of `.repo.gc(…)`
py-ipfs-http-client 0.7.0 (15.03.2021)
--------------------------------------

View File

@@ -16,8 +16,8 @@ See the [relevant section of the CHANGELOG](CHANGELOG.md#py-ipfs-http-client-041
unmaintained and does not work with any recent go-IPFS version.
**Note**: This library occasionally has to change to stay compatible with the IPFS HTTP API.
Currently, this library is tested against [go-ipfs v0.7.0](https://github.com/ipfs/go-ipfs/releases/tag/v0.7.0).
We strive to support the last 5 releases of go-IPFS at any given time; go-IPFS v0.4.23 therefore
Currently, this library is tested against [go-ipfs v0.8.0](https://github.com/ipfs/go-ipfs/releases/tag/v0.8.0).
We strive to support the last 5 releases of go-IPFS at any given time; go-IPFS v0.5.0 therefore
being to oldest supported version at this time.
## Table of Contents

View File

@@ -14,9 +14,12 @@ import multiaddr
DEFAULT_ADDR = multiaddr.Multiaddr(os.environ.get("PY_IPFS_HTTP_CLIENT_DEFAULT_ADDR", '/dns/localhost/tcp/5001/http'))
DEFAULT_BASE = str(os.environ.get("PY_IPFS_HTTP_CLIENT_DEFAULT_BASE", 'api/v0'))
VERSION_MINIMUM = "0.4.23"
# This range inclusive-exclusive, so the daemon version must match
# `VERSION_MINIMUM <= version < VERSION_MAXIMUM`
# for it to be considered compatible.
VERSION_MINIMUM = "0.5.0"
VERSION_BLACKLIST = []
VERSION_MAXIMUM = "0.8.0"
VERSION_MAXIMUM = "0.9.0"
from . import bitswap
from . import block
@@ -229,11 +232,6 @@ class Client(files.Base, miscellaneous.Base):
version = tuple(map(int, version_info["Version"].split('-', 1)[0].split('.')))
self._workarounds.clear()
if version < (0, 5): # pragma: no cover (workaround)
# Not really a workaround, but make use of HEAD requests on versions
# that support them to speed things up if we are not interested in the
# response anyways
self._workarounds.add("use_http_head_for_no_result")
return version_info

View File

@@ -1,11 +1,9 @@
import warnings
from . import base
class Section(base.SectionBase):
@base.returns_multiple_items(base.ResponseBase)
def gc(self, *, quiet: bool = False, return_result: bool = True, **kwargs: base.CommonArgs):
def gc(self, *, quiet: bool = False, **kwargs: base.CommonArgs):
"""Removes stored objects that are not pinned from the repo
.. code-block:: python
@@ -30,27 +28,13 @@ class Section(base.SectionBase):
Passing ``True`` to this parameter often causing the GC process to
speed up tremendously as it will also avoid generating the list of
removed objects in the connected daemon at all.
return_result
If ``False`` this is a legacy alias for ``quiet=True``.
(Will be dropped in py-ipfs-api-client 0.7.x!)
Returns
-------
dict
List of IPFS objects that have been removed
"""
if not return_result:
warnings.warn("Parameter `return_result` of `.repo.gc(…)` is deprecated "
"in favour of the newer `quiet` parameter", DeprecationWarning)
quiet = quiet or not return_result
if "use_http_head_for_no_result" not in self._client.workarounds:
# go-ipfs 0.4.22- does not support the quiet option yet
kwargs.setdefault("opts", {})["quiet"] = quiet
kwargs.setdefault("return_result", not quiet)
kwargs.setdefault("opts", {})["quiet"] = quiet
return self._client.request('/repo/gc', decoder='json', **kwargs)

View File

@@ -605,11 +605,7 @@ class ClientSyncBase(ty.Generic[S], metaclass=abc.ABCMeta):
if not return_result:
decoder = "none"
# HTTP method must always be "POST" since go-IPFS 0.5
method = "POST"
if "use_http_head_for_no_result" in self.workarounds and not return_result: # pragma: no cover
method = "HEAD"
parser = encoding.get_encoding(decoder)
closables, res = self._request(

View File

@@ -21,18 +21,3 @@ def test_gc(client):
assert orig_objs > cur_objs
keys = [el["Key"]["/"] for el in gc]
assert garbage in keys
def test_gc_no_result(client):
# Add and unpin an object to be garbage collected
garbage = client.add_str("Test String")
client.pin.rm(garbage)
# Collect the garbage object with object count before and after
orig_objs = client.repo.stat()["NumObjects"]
gc = client.repo.gc(quiet=True)
cur_objs = client.repo.stat()["NumObjects"]
# Verify the garbage object was collected
assert orig_objs > cur_objs
assert gc is None