Commits (2)
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "str_util.h" #include "str_util.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include "git_branch.h"
#include "git_hash.h"
#define DELFILES_VER "3.19" #define DELFILES_VER "3.19"
...@@ -89,7 +91,6 @@ bool delfile(const char *filename) ...@@ -89,7 +91,6 @@ bool delfile(const char *filename)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char revision[16];
char str[256],not[MAX_NOTS][LEN_EXTCODE + 1],nots=0,*p; char str[256],not[MAX_NOTS][LEN_EXTCODE + 1],nots=0,*p;
char fpath[MAX_PATH+1]; char fpath[MAX_PATH+1];
int i,j,dirnum,libnum; int i,j,dirnum,libnum;
...@@ -101,10 +102,8 @@ int main(int argc, char **argv) ...@@ -101,10 +102,8 @@ int main(int argc, char **argv)
setvbuf(stdout,NULL,_IONBF,0); setvbuf(stdout,NULL,_IONBF,0);
sscanf("$Revision: 1.54 $", "%*s %s", revision); fprintf(stderr,"\nDELFILES Version %s-%s %s/%s - Removes files from Synchronet "
"Filebase\n" ,DELFILES_VER, PLATFORM_DESC, GIT_BRANCH, GIT_HASH);
fprintf(stderr,"\nDELFILES Version %s-%s (rev %s) - Removes files from Synchronet "
"Filebase\n" ,DELFILES_VER, PLATFORM_DESC, revision);
if(argc<2) { if(argc<2) {
printf("\n usage: %s <dir_code or * for ALL> [switches]\n", argv[0]); printf("\n usage: %s <dir_code or * for ALL> [switches]\n", argv[0]);
...@@ -243,7 +242,7 @@ int main(int argc, char **argv) ...@@ -243,7 +242,7 @@ int main(int argc, char **argv)
printf("\nScanning %s %s\n", cfg.lib[cfg.dir[i]->lib]->sname, cfg.dir[i]->lname); printf("\nScanning %s %s\n", cfg.lib[cfg.dir[i]->lib]->sname, cfg.dir[i]->lname);
size_t file_count; size_t file_count;
file_t* file_list = loadfiles(&smb, NULL, 0, /* extdesc: */FALSE, FILE_SORT_NATURAL, &file_count); file_t* file_list = loadfiles(&smb, NULL, /* since: */0, file_detail_normal, FILE_SORT_NATURAL, &file_count);
for(fi = 0; fi < file_count; fi++) { for(fi = 0; fi < file_count; fi++) {
file_t* f = &file_list[fi]; file_t* f = &file_list[fi];
......
...@@ -385,6 +385,7 @@ int smb_removefile(smb_t* smb, smbfile_t* file) ...@@ -385,6 +385,7 @@ int smb_removefile(smb_t* smb, smbfile_t* file)
{ {
int result; int result;
int removed = 0; int removed = 0;
char fname[SMB_FILEIDX_NAMELEN + 1] = "";
if(!smb->locked && smb_locksmbhdr(smb) != SMB_SUCCESS) if(!smb->locked && smb_locksmbhdr(smb) != SMB_SUCCESS)
return SMB_ERR_LOCK; return SMB_ERR_LOCK;
...@@ -411,6 +412,7 @@ int smb_removefile(smb_t* smb, smbfile_t* file) ...@@ -411,6 +412,7 @@ int smb_removefile(smb_t* smb, smbfile_t* file)
smb_close_da(smb); smb_close_da(smb);
// Now remove from index: // Now remove from index:
smb_fileidxname(file->name, fname, sizeof(fname));
if(result == SMB_SUCCESS) { if(result == SMB_SUCCESS) {
rewind(smb->sid_fp); rewind(smb->sid_fp);
fileidxrec_t* fidx = malloc(smb->status.total_files * sizeof(*fidx)); fileidxrec_t* fidx = malloc(smb->status.total_files * sizeof(*fidx));
...@@ -425,7 +427,7 @@ int smb_removefile(smb_t* smb, smbfile_t* file) ...@@ -425,7 +427,7 @@ int smb_removefile(smb_t* smb, smbfile_t* file)
} }
rewind(smb->sid_fp); rewind(smb->sid_fp);
for(uint32_t i = 0; i < smb->status.total_files; i++) { for(uint32_t i = 0; i < smb->status.total_files; i++) {
if(stricmp(fidx[i].name, file->name) == 0) { if(stricmp(fidx[i].name, fname) == 0) {
removed++; removed++;
continue; continue;
} }
...@@ -439,8 +441,8 @@ int smb_removefile(smb_t* smb, smbfile_t* file) ...@@ -439,8 +441,8 @@ int smb_removefile(smb_t* smb, smbfile_t* file)
free(fidx); free(fidx);
if(result == SMB_SUCCESS) { if(result == SMB_SUCCESS) {
if(removed < 1) { if(removed < 1) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s name found: %s" safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s name not found: %s"
,__FUNCTION__, file->name); ,__FUNCTION__, fname);
result = SMB_ERR_NOT_FOUND; result = SMB_ERR_NOT_FOUND;
} else { } else {
fflush(smb->sid_fp); fflush(smb->sid_fp);
......