echo "Moving ${removal_path} to /tmp/${removes[$removal_path]}"
mv "${path_to_songs}/${removal_path}" "/tmp/${removes[$removal_path]}"
+ crc32="$(echo -n "/Songs/${removal_path}/" | gzip -c | tail -c8 | hexdump -n4 -e '"%u"')"
+ rm "${path_to_song_cache}/${crc32}"
+
+ pack_dir=$(echo "$removal_path" | cut -sd / -f1)
+ count="$( find "${path_to_songs}/${pack_dir}" -mindepth 1 -maxdepth 1 | wc -l )"
+ if [ $count -eq 0 ] ; then
+ echo "${pack_dir} is now empty, deleting"
+ rmdir "${path_to_songs}/${pack_dir}"
+ fi
+
done
for add_path in "${!adds[@]}"; do
rm "${path_to_song_cache}/${crc32}"
fi
+ if ! [ -d "${path_to_songs}/${add_path}" ]; then
+ echo "Creating dir for: ${add_path}"
+ mkdir -p "${path_to_songs}/${pack_dir}"
+ fi
+
# The file existed previously, just move that over.
if [ -d "/tmp/${adds[$add_path]}" ]; then
echo "Moving /tmp/${adds[$add_path]} to ${path_to_songs}/${add_path}"
continue
fi
- echo "Creating dir for: ${add_path}"
- mkdir -p "${path_to_songs}/${pack_dir}"
echo "Downloading files"
escaped_add_path="/mnt/media/Simfiles/"$(echo "$add_path" | sed 's/ /\\\\\\ /g' | sed "s/'/\\\\\\\\\\\'/g" | sed "s/(/\\\\\\\\\\\\(/g" | sed "s/)/\\\\\\\\\\\\\\)/g" | sed "s/&/\\\\\\\\\\\&/g" | sed "s/\`/\\\\\\\\\\\\\`/g")
scp_command="scp -r groovenet@cameron1729.xyz:$escaped_add_path \"${path_to_songs}/${pack_dir}\""