diff --git a/ChangeLog b/ChangeLog index 49660a2f..948e5c57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ === rmw ChangeLog === +2025-10-20 + * (bugfix) Allow rmw to move directories to waste folder on btrfs filesystems + 2024-11-07 * Update ChangeLog to note btrfs cloning is supported only on Linux diff --git a/src/main.c b/src/main.c index 1a3f2eec..b0cc68d9 100644 --- a/src/main.c +++ b/src/main.c @@ -367,6 +367,8 @@ damage of 5000 hp. You feel satisfied.\n")); printf(_("%s resides within a waste folder and has been ignored\n"), argv[file_arg]); is_protected = 1; + if (getenv("RMW_FAKE_HOME")) + n_err++; break; } waste_curr = waste_curr->next_node; @@ -410,7 +412,7 @@ damage of 5000 hp. You feel satisfied.\n")); int r_result = 0; if (cli_user_options->want_dry_run == false) { - if (waste_curr->dev_num != st_target.dev_num) + if ((waste_curr->dev_num != st_target.dev_num) && !S_ISDIR(st_file_arg.st_mode)) { int save_errno = errno; r_result = @@ -805,7 +807,7 @@ Please check your configuration file and permissions\ st_location, &cli_user_options); - if (result > 1) + if (result) { dispose_waste(st_config_data.st_waste_folder_props_head); /* Don't need to print any messages here. Any warnings or errors diff --git a/test/test_basic.sh b/test/test_basic.sh index 3b3a8266..62bc0f1c 100755 --- a/test/test_basic.sh +++ b/test/test_basic.sh @@ -63,12 +63,12 @@ test "$output" = "6" echo "$SEPARATOR" echo " == rmw should refuse to move a waste folder or a file that resides within a waste folder" -output="$($RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info)" +output="$($RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info || true)" test "${output}" = " :warning: "$PRIMARY_WASTE_DIR"/info resides within a waste folder and has been ignored 0 items were removed to the waste folder" # If the file gets removed (which it shouldn't), then the test that follows it will fail -$RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info/1.trashinfo +$RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info/1.trashinfo || true echo "\n\n == Display contents of 1.trashinfo " cat "$PRIMARY_WASTE_DIR"/info/1.trashinfo diff --git a/test/test_btrfs_clone.sh b/test/test_btrfs_clone.sh index a38c1981..4f791c44 100755 --- a/test/test_btrfs_clone.sh +++ b/test/test_btrfs_clone.sh @@ -27,7 +27,21 @@ fi cd "$BTRFS_IMAGE_MOUNTPOINT" RMW_TEST_CMD_STRING="$BIN_DIR/rmw -c ${MESON_SOURCE_ROOT}/test/conf/btrfs_img.testrc" -WASTE_USED="/tmp/rmw-loop/three/Waste" + +SUBVOLUME_USED="/tmp/rmw-loop/three" + +WASTE_USED="$SUBVOLUME_USED/Waste" +if [ -d "$WASTE_USED" ]; then + rm -rf "$WASTE_USED" +fi + +TEST_DIR="$SUBVOLUME_USED/test_dir" +if [ -d "$TEST_DIR" ]; then + rm -rf "$TEST_DIR" +fi + +mkdir "$TEST_DIR" +$RMW_TEST_CMD_STRING -v "$TEST_DIR" touch foo $RMW_TEST_CMD_STRING foo