Prevent shared directory names from being duplicated

Prevent directory duplication and add index mechanism
This commit is contained in:
ncheng89 2024-12-26 15:55:25 +08:00 committed by GitHub
parent eb8775bec7
commit c3f5af3761
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -88,10 +88,12 @@ addShare "$share" "Data" "Shared" || error "Failed to create shared folder!"
IFS=',' read -r -a dirs <<< "${SHARED_DIRS:-}"
# Traverse the directory and create shares
index_dir=1
for dir in "${dirs[@]}"; do
if [ -d "$dir" ]; then
dir_name=$(basename "$dir")
addShare "$dir" "$dir_name" "Shared $dir_name" || error "Failed to create shared folder for $dir!"
addShare "$dir" "${dir_name}_${index_dir}" "Shared $dir_name" || error "Failed to create shared folder for $dir!"
((index_dir++))
fi
done