Skip to content

Commit

Permalink
[FC-42124] make the deploymenttrash trash dir configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilTaken committed Nov 27, 2024
1 parent 81197ce commit b80ac62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- make the DeploymentTrash's trash directory configurable and output a potentially helpful message on OSErrors which could indicate that the trash directory and the directory that is being trashed are on different devices
11 changes: 10 additions & 1 deletion src/batou_ext/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ class DeploymentTrash(batou.component.Component):
read_iops_limit = 100
write_iops_limit = 100

trashdir = None

def configure(self):
self.trashdir = os.path.expanduser("~/.deployment-trash")
if not self.trashdir:
self.trashdir = os.path.expanduser("~/.deployment-trash")

self += batou.lib.file.File(self.trashdir, ensure="directory")
self += batou.lib.file.File(
"/etc/local/nixos/trash.nix",
Expand All @@ -194,3 +198,8 @@ def discard(self, path):
except FileNotFoundError:
# Nothing to delete.
pass
except OSError as e:
batou.output.annotate(
"check that the deployment trash dir and the directory you want to trash are on the same device"
)
raise e

0 comments on commit b80ac62

Please sign in to comment.