--- afd-1.3.2/src/amg/search_old_files.c 2006-02-12 12:16:45.000000000 +0100 +++ afd/src/amg/search_old_files.c 2006-04-24 16:41:46.000000000 +0200 @@ -88,11 +88,13 @@ void search_old_files(time_t current_time) { - int i, + int i, j, k, delete_file, junk_files, - file_counter; - time_t diff_time; + file_counter, + ret; + time_t diff_time, + pmatch_time; char *ptr, *work_ptr, tmp_dir[MAX_PATH_LENGTH]; @@ -154,10 +156,15 @@ * leading dot. */ diff_time = current_time - stat_buf.st_mtime; + if (diff_time < 0) + { + diff_time = 0; + } if (((p_dir->d_name[0] == '.') && (fra[de[i].fra_pos].unknown_file_time == 0) && (diff_time > 3600)) || - (diff_time > fra[de[i].fra_pos].unknown_file_time)) + ((diff_time > 5L) && + (diff_time > fra[de[i].fra_pos].unknown_file_time))) { if ((fra[de[i].fra_pos].delete_files_flag & UNKNOWN_FILES) || (p_dir->d_name[0] == '.')) @@ -176,7 +183,39 @@ } else { - delete_file = YES; + if (de[i].flag & ALL_FILES) + { + delete_file = NO; + } + else + { + delete_file = YES; + if (de[i].paused_dir == NULL) + { + pmatch_time = current_time; + } + else + { + pmatch_time = stat_buf.st_mtime; + } + for (j = 0; j < de[i].nfg; j++) + { + for (k = 0; ((k < de[i].fme[j].nfm) && (j < de[i].nfg)); k++) + { + if ((ret = pmatch(de[i].fme[j].file_mask[k], + p_dir->d_name, + &pmatch_time)) == 0) + { + delete_file = NO; + j = de[i].nfg; + } + else if (ret == 1) + { + break; + } + } + } + } } if (delete_file == YES) { @@ -201,11 +240,12 @@ dl_real_size = *dl.file_name_length + dl.size + sprintf((dl.file_name + *dl.file_name_length + 1), # if SIZEOF_TIME_T == 4 - "dir_check() >%ld", + "dir_check() >%ld (%s %d)", # else - "dir_check() >%lld", + "dir_check() >%lld (%s %d)", # endif - diff_time); + diff_time, + __FILE__, __LINE__); if (write(dl.fd, dl.data, dl_real_size) != dl_real_size) { system_log(ERROR_SIGN, __FILE__, __LINE__, @@ -288,6 +328,10 @@ if (S_ISREG(stat_buf.st_mode)) { diff_time = current_time - stat_buf.st_mtime; + if (diff_time < 0) + { + diff_time = 0; + } if (diff_time > fra[de[i].fra_pos].queued_file_time) { if (unlink(tmp_dir) == -1) @@ -312,11 +356,12 @@ dl_real_size = *dl.file_name_length + dl.size + sprintf((dl.file_name + *dl.file_name_length + 1), # if SIZEOF_TIME_T == 4 - "dir_check() >%ld", + "dir_check() >%ld (%s %d)", # else - "dir_check() >%lld", + "dir_check() >%lld (%s %d)", # endif - diff_time); + diff_time, + __FILE__, __LINE__); if (write(dl.fd, dl.data, dl_real_size) != dl_real_size) { system_log(ERROR_SIGN, __FILE__, __LINE__,