Fix get_restic_config not applied when guard misfires; detect stubs in native check
The guard in the b2.py patch block skipped setting get_restic_config when something caused B2RcloneRemote.__dict__ to already contain it at import time (e.g. a TrueNAS version that adds a NotImplementedError stub). Remove the guard and always assign, which is safe: the native-support kill switch already prevents patching when TrueNAS ships a real implementation. Also update the native-support check to distinguish a stub (source contains NotImplementedError) from a working implementation, so a stub does not trigger the kill switch and block all future patching.
This commit is contained in:
+9
-2
@@ -111,7 +111,15 @@ try:
|
|||||||
print('no')
|
print('no')
|
||||||
else:
|
else:
|
||||||
src = open(inspect.getfile(_b2_mod), encoding='utf-8', errors='replace').read()
|
src = open(inspect.getfile(_b2_mod), encoding='utf-8', errors='replace').read()
|
||||||
print('no' if 'TRUECLOUD_PATCH' in src else 'yes')
|
if 'TRUECLOUD_PATCH' in src:
|
||||||
|
print('no')
|
||||||
|
else:
|
||||||
|
# Distinguish a real implementation from a stub that raises NotImplementedError.
|
||||||
|
try:
|
||||||
|
method_src = inspect.getsource(B2RcloneRemote.get_restic_config)
|
||||||
|
except (OSError, TypeError):
|
||||||
|
method_src = ''
|
||||||
|
print('no' if 'NotImplementedError' in method_src else 'yes')
|
||||||
except Exception:
|
except Exception:
|
||||||
print('no')
|
print('no')
|
||||||
" 2>/dev/null || echo "no")
|
" 2>/dev/null || echo "no")
|
||||||
@@ -184,7 +192,6 @@ def _tc_get_restic_config(task):
|
|||||||
p = task["credentials"]["provider"]
|
p = task["credentials"]["provider"]
|
||||||
return "", {"B2_ACCOUNT_ID": p["account"], "B2_ACCOUNT_KEY": p["key"]}
|
return "", {"B2_ACCOUNT_ID": p["account"], "B2_ACCOUNT_KEY": p["key"]}
|
||||||
|
|
||||||
if "get_restic_config" not in B2RcloneRemote.__dict__:
|
|
||||||
B2RcloneRemote.get_restic_config = staticmethod(_tc_get_restic_config)
|
B2RcloneRemote.get_restic_config = staticmethod(_tc_get_restic_config)
|
||||||
B2RcloneRemote.restic = True
|
B2RcloneRemote.restic = True
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user