From fd8a9a7c984c23928bc30038223658fee5ac60dd Mon Sep 17 00:00:00 2001 From: David Kebler Date: Sat, 7 Dec 2024 13:42:53 -0800 Subject: [PATCH] fix copy and bindfs --- modules/filesystem/btrfs/btrfs.mod | 3 +- modules/utility/bindfs.lib | 8 ++- modules/utility/cache-trash-log.exc | 1 - modules/utility/copy.lib | 95 +++++++++++++++++++---------- 4 files changed, 71 insertions(+), 36 deletions(-) diff --git a/modules/filesystem/btrfs/btrfs.mod b/modules/filesystem/btrfs/btrfs.mod index 5b172f7..e947ab1 100644 --- a/modules/filesystem/btrfs/btrfs.mod +++ b/modules/filesystem/btrfs/btrfs.mod @@ -2,6 +2,7 @@ export BTRFS_BIN=$(which btrfs) module_load confirm module_load helpers +module_load path # NOTE: set this for sudo # ALL ALL = (root) NOPASSWD:/bin/btrfs @@ -182,7 +183,7 @@ snapshot_send() { echo "[[ "$tsnap" ]] && sudo $BTRFS_BIN sub del $tsnap" else sudo $BTRFS_BIN send $([[ $tsnap ]] && echo $tsnap || echo $src) | btrfs receive $dest - mv $dest/$snap $dest/$name$ext + sudo mv $dest/$snap $dest/$name$ext [[ "$tsnap" ]] && sudo $BTRFS_BIN sub del $tsnap echo transfer is complete ls -la $dest diff --git a/modules/utility/bindfs.lib b/modules/utility/bindfs.lib index 29b9726..adf56db 100644 --- a/modules/utility/bindfs.lib +++ b/modules/utility/bindfs.lib @@ -17,9 +17,11 @@ if [ -v PS1 ]; then alias bfs="dir_bind" alias bfsum="dir_bind_unmount" alias bfse="bfs_vscode" - - sudo mkdir $BFS_MOUNT_DIR 2> /dev/null - sudo chown $USER:$USER $BFS_MOUNT_DIR + + if [[ ! -d $BFS_MOUNT_DIR ]]; then + sudo mkdir $BFS_MOUNT_DIR 2> /dev/null + sudo chown $USER:$USER $BFS_MOUNT_DIR + fi fi mounted () { diff --git a/modules/utility/cache-trash-log.exc b/modules/utility/cache-trash-log.exc index 3c6a166..fbf7d1e 100644 --- a/modules/utility/cache-trash-log.exc +++ b/modules/utility/cache-trash-log.exc @@ -1,6 +1,5 @@ *[Tt]rash/ tmp/* -node_modules/* *[Cc]ache/* *[lL]ogs/* [Ll]og/* diff --git a/modules/utility/copy.lib b/modules/utility/copy.lib index 15400a9..8d488ac 100644 --- a/modules/utility/copy.lib +++ b/modules/utility/copy.lib @@ -21,7 +21,7 @@ copy () { cat < source destination -- +rsync