Closed couriersud closed 1 month ago
We could easily add rmdir
to the busybox build.
However I dont know why that snippet is not just using find to delete empty folders, something like the commented out code
find <path> -type d -empty -delete
Edit: rmdir
is built its just missing the symlink
busybox find
doesnt include the -empty
command, but something like this should work
From 9935c41fd2827279ee5f81a0d69905605e09f6fa Mon Sep 17 00:00:00 2001
From: Tim Lunn <tim@feathertop.org>
Date: Tue, 4 Apr 2023 23:12:57 +1000
Subject: [PATCH] fix rmdir
---
src/busybox/install.busybox | 2 ++
src/static/static/sonoff-hack/script/ftppush.sh | 5 +----
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/busybox/install.busybox b/src/busybox/install.busybox
index 4043b2d..5aadf1e 100755
--- a/src/busybox/install.busybox
+++ b/src/busybox/install.busybox
@@ -15,3 +15,5 @@ echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/wget
chmod 0755 ../../build/sonoff-hack/usr/bin/wget
echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/xargs
chmod 0755 ../../build/sonoff-hack/usr/bin/xargs
+echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/rmdir
+chmod 0755 ../../build/sonoff-hack/usr/bin/rmdir
diff --git a/src/static/static/sonoff-hack/script/ftppush.sh b/src/static/static/sonoff-hack/script/ftppush.sh
index ddf4d2c..4a7c5f8 100755
--- a/src/static/static/sonoff-hack/script/ftppush.sh
+++ b/src/static/static/sonoff-hack/script/ftppush.sh
@@ -89,10 +89,7 @@ checkFiles ()
#
# Delete empty sub directories
if [ ! -z "${FOLDER_TO_WATCH}" ]; then
- for d in $(find "${FOLDER_TO_WATCH}/" -mindepth 1 -type d); do
- #find "${FOLDER_TO_WATCH}/" -mindepth 1 -type d -empty -delete
- [ -z "`find $d -type f`" ] && rmdir $d
- done
+ find "${FOLDER_TO_WATCH}/" -mindepth 1 -depth -type d -exec rmdir --ignore-fail-on-non-empty {} \;
fi
#
return 0
--
2.37.2
Ok, thanks, will give it a try. Shouldn't this become a pull request?
yes, but I hadnt tested it at all yet
Once PR #141 is applied this issue can be closed.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
ftppush (master) currently fails to remove empty folders. It uses
rmdir
which does not exist in the firmware. Replacingrmdir
withrm -rf
works, but is more risky since rmdir would fail on non-empty folders.