mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
vfs: Fixed directory switch
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
191d2df6ec
commit
2f6485a32e
1 changed files with 16 additions and 10 deletions
22
bin/vfs
22
bin/vfs
|
|
@ -56,14 +56,20 @@ function vfs.path.real file {
|
||||||
function :switch storage {
|
function :switch storage {
|
||||||
target="$(vfs.path "$storage")"
|
target="$(vfs.path "$storage")"
|
||||||
nux.log debug "Target path $target"
|
nux.log debug "Target path $target"
|
||||||
for f in "$@" ; do
|
for arg_path in "$@" ; do
|
||||||
relative_path=$(realpath --relative-to="$CURRENT_MOUNT" $f);
|
rooted_path="/$(realpath -m --relative-to="$CURRENT_MOUNT" ${arg_path%/})";
|
||||||
target_dir="$target/${relative_path%/*}"
|
target_dir="${target}${rooted_path%/*}"
|
||||||
real_file="$(vfs.path.real "$relative_path")"
|
real_file="$(vfs.path.real "$rooted_path")"
|
||||||
nux.log debug "Target directory: $target_dir";
|
nux.log trace "Rooted path: $rooted_path";
|
||||||
nuxfs.info $f moving from "$NC_LightPurple${real_file}$NC_No" to "$NC_LightPurple$target_dir"
|
nux.log trace "Real file: $real_file";
|
||||||
|
nux.log trace "Target dir: $target_dir";
|
||||||
|
if [ -n "$real_file" ]; then
|
||||||
mkdir -p "$target_dir";
|
mkdir -p "$target_dir";
|
||||||
|
nuxfs.info $arg_path moving from "$NC_LightPurple${real_file}$NC_No" to "$NC_LightPurple$target_dir"
|
||||||
mv "$real_file" "$target_dir";
|
mv "$real_file" "$target_dir";
|
||||||
|
else
|
||||||
|
nuxfs.error $arg_path does not exists.
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
## mount:: <target> <name:path> [<name:path>+]
|
## mount:: <target> <name:path> [<name:path>+]
|
||||||
|
|
@ -82,7 +88,7 @@ function vfs.path.real file {
|
||||||
mount_paths="$mount_paths:${source_path}"
|
mount_paths="$mount_paths:${source_path}"
|
||||||
echo "$source_name $source_path" >> "$source_tempfs/.vfs.sources"
|
echo "$source_name $source_path" >> "$source_tempfs/.vfs.sources"
|
||||||
done
|
done
|
||||||
echo "temp $source_tempfs" >> "$source_tempfs/$VFS_SOURCES_FILE"
|
echo "temp $source_tempfs" >> "$source_tempfs/$VFS_SOURCES_FILE="
|
||||||
|
|
||||||
mergerfs_options="$source_tempfs:${mount_paths}"
|
mergerfs_options="$source_tempfs:${mount_paths}"
|
||||||
nux.log debug "MergerFS command:" $mergerfs_options;
|
nux.log debug "MergerFS command:" $mergerfs_options;
|
||||||
|
|
@ -91,7 +97,7 @@ function vfs.path.real file {
|
||||||
}
|
}
|
||||||
## unmount:: <target>
|
## unmount:: <target>
|
||||||
## Unmounts target VFS filesystem.
|
## Unmounts target VFS filesystem.
|
||||||
function :unmount {
|
function :unmount target {
|
||||||
fusermount -u "$target"
|
fusermount -u "$target"
|
||||||
nuxfs.info "${CURRENT_SOURCES[temp]}" removing temporary metadata.
|
nuxfs.info "${CURRENT_SOURCES[temp]}" removing temporary metadata.
|
||||||
rm -rf "${CURRENT_SOURCES[temp]}"
|
rm -rf "${CURRENT_SOURCES[temp]}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue