Skip to content

Commit

Permalink
Merge pull request #203 from flyingcircusio/phil/FC-42124_make_deploy…
Browse files Browse the repository at this point in the history
…menttrashdir_configurable

[FC-42124] make the deploymenttrash trash dir configurable
  • Loading branch information
frlan authored Nov 28, 2024
2 parents 81197ce + 2c5f426 commit 9b03de0
Show file tree
Hide file tree
Showing 2 changed files with 13 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
13 changes: 12 additions & 1 deletion src/batou_ext/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SymlinkAndCleanup(batou.component.Component):

systemd_read_max_iops = 100
systemd_write_max_iops = 100
trashdir = None

## DEPRECATED, do not use
use_systemd_run_async_cleanup = False
Expand All @@ -56,6 +57,7 @@ def configure(self):
self += DeploymentTrash(
read_iops_limit=self.systemd_read_max_iops,
write_iops_limit=self.systemd_write_max_iops,
trashdir=self.trashdir,
)
self.trash = self._

Expand Down Expand Up @@ -166,8 +168,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 +200,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 9b03de0

Please sign in to comment.