summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-07-22 21:46:55 +0200
committerOskar <[email protected]>2024-07-22 21:46:55 +0200
commit931180350725b1675179484130b16aa09dca711a (patch)
tree48952e45f2c1e2d97b873a6a3897e6cab8b812f4
parent0e62cf93c8f27f75c55973a1be6f6cf0d47759e4 (diff)
more test scripts to generate files and directories, and some improvements
-rwxr-xr-xtest/test_dirs_subdirs.sh10
-rw-r--r--trashsys.c5
2 files changed, 13 insertions, 2 deletions
diff --git a/test/test_dirs_subdirs.sh b/test/test_dirs_subdirs.sh
new file mode 100755
index 0000000..7349272
--- /dev/null
+++ b/test/test_dirs_subdirs.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+mkdir -p testdir/testdir2/testdir3/{td1,td2,td3,td4,td5}
+
+cd testdir
+../gentestfiles.sh
+cd testdir2/testdir3/td1
+../../../../gentestfiles.sh
+cd ../td2
+../../../../gentestfiles.sh
diff --git a/trashsys.c b/trashsys.c
index bd9bf78..a09afbb 100644
--- a/trashsys.c
+++ b/trashsys.c
@@ -916,18 +916,19 @@ int clear_old_files (int file_age_in_days, struct initial_path_info *ipi) {
fprintf(stderr, "Paths are too long. Continuing to next file.\n");
continue;
}
+ int rm1;
int rm2;
struct stat s;
stat(cur_trashed_path, &s);
if(S_ISDIR(s.st_mode)) {
cvm_fprintf(v_cvm_fprintf, stdout, "clear_old_files: dir\n");
+ rm1 = remove(cur_log_path);
rm2 = nftw(cur_trashed_path, remove_nftw, 64, FTW_DEPTH | FTW_PHYS);
- continue;
} else {
+ rm1 = remove(cur_log_path);
rm2 = remove(cur_trashed_path);
}
- int rm1 = remove(cur_log_path);
if(rm1 == -1 || rm2 == -1) {
if(rm1 == -1) {fprintf(stdout, "failed to remove: %s\n", cur_log_path);}
if(rm2 == -1) {fprintf(stdout, "failed to remove: %s\n", cur_trashed_path);}