Skip to content

Commit

Permalink
Do not delete if read fail due to version difference
Browse files Browse the repository at this point in the history
  • Loading branch information
zwimer committed Sep 23, 2024
1 parent b438995 commit 17f1642
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion rpipe/client/client/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ def delete(full_conf: Config) -> None:


@contextmanager
def delete_on_fail(config: Config):
def delete_on_fail(config: Config, allow: tuple[type[BaseException], ...] = ()):
"""
Context manager that deletes the channel on failure
"""
log = getLogger("DeleteOnFail")
try:
yield
except allow:
raise
except (KeyboardInterrupt, Exception) as e:
log.warning("Caught %s; deleting channel", type(e))
delete(config)
Expand Down
2 changes: 1 addition & 1 deletion rpipe/client/client/recv.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def recv(config: Config, peek: bool, force: bool, progress: bool | int) -> None:
log.info("Reading from channel %s with peek=%s and force=%s", config.channel, peek, force)
params = DownloadRequestParams(version=version, override=force, delete=not peek)
lvl: int | None = 0
with delete_on_fail(config):
with delete_on_fail(config, allow=(VersionError,)):
with PBar(progress) as pbar:
while lvl is not None:
lvl = _recv_body(config, peek, url, params, pbar, lvl)
Expand Down
2 changes: 1 addition & 1 deletion rpipe/shared/version_.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations


__version__: str = "8.1.0" # Must be "<major>.<minor>.<patch>", all numbers
__version__: str = "8.1.1" # Must be "<major>.<minor>.<patch>", all numbers


class Version:
Expand Down

0 comments on commit 17f1642

Please sign in to comment.