diff --git a/README.md b/README.md index 311923a..1848111 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Don't worry, they're easy to remember after a minute: All of **bak**'s commands will disambiguate between multiple copies of the same file. In other words, you can `bak my_thing.txt` as many times as you want, until you're finished working, if you'd prefer to keep multiples instead of using `bak up`. At the moment, all you've got to go by are timestamps when it asks you to pick a .bakfile, but this will improve. +**NOTE:** `bak down` will fall back on `sudo cp` if necessary. Please don't run `sudo bak`. This may create parallel config and bakfiles in root's XDG directories. + ## Additional commands and flags `bak down --keep my_file` - Restores from .bakfile, does not delete .bakfile diff --git a/bak/__init__.py b/bak/__init__.py index baaa46e..714b40c 100644 --- a/bak/__init__.py +++ b/bak/__init__.py @@ -1 +1 @@ -BAK_VERSION = "0.1.0a1" +BAK_VERSION = "0.1.1a1" diff --git a/bak/commands/__init__.py b/bak/commands/__init__.py index d06d79a..530e3d7 100644 --- a/bak/commands/__init__.py +++ b/bak/commands/__init__.py @@ -225,6 +225,10 @@ def bak_up_cmd(filename: Path): db_handler.update_bakfile_entry(old_bakfile) return True +def _sudo_bak_down_helper(src, dest): + # TODO spin this off into a separate exec for sanity + click.echo(f"The destination {dest} is privileged. Falling back on 'sudo cp'") + call(f"sudo cp {src} {dest}".split(" ")) def bak_down_cmd(filename: Path, destination: Optional[Path], @@ -270,7 +274,11 @@ def bak_down_cmd(filename: Path, if not confirm: console.print("Cancelled.") return - copy2(bakfile_entry.bakfile_loc, destination) + + try: + copy2(bakfile_entry.bakfile_loc, destination) + except PermissionError: + _sudo_bak_down_helper(bakfile_entry.bakfile_loc, destination) if not keep_bakfile: for entry in bakfile_entries: Path(entry.bakfile_loc).unlink(missing_ok=True) diff --git a/setup.py b/setup.py index 786cd21..eccc1ec 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ 'rich==9.1.0'] setup(name='bak', - version='0.1.0a1', + version='0.1.1a1', description='the .bak manager', author='ChanceNCounter', author_email='ChanceNCounter@icloud.com',