Made searching file file_id.diz case insensitive

This commit is contained in:
Michiel Broek 2006-01-06 20:06:57 +00:00
parent ae23be1f25
commit 17a709b972
4 changed files with 36 additions and 49 deletions

View File

@ -2,6 +2,13 @@ $Id$
v0.83.7 31-Dec-2005 v0.83.7 31-Dec-2005
mbfido:
Made searching file file_id.diz case insensitive.
mbfile:
Made searching file file_id.diz case insensitive.
v0.83.6 17-Dec-2005 - 31-Dec-2005 v0.83.6 17-Dec-2005 - 31-Dec-2005
mbfido: mbfido:

View File

@ -4,7 +4,7 @@
* Purpose: File Database Maintenance - Adopt file * Purpose: File Database Maintenance - Adopt file
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -46,7 +46,7 @@ extern int do_novir; /* Suppress virus check */
void AdoptFile(int Area, char *File, char *Description) void AdoptFile(int Area, char *File, char *Description)
{ {
FILE *fp; FILE *fp;
char *temp, *temp2, *tmpdir, *unarc, *pwd, *lname; char *temp, *temp2, *tmpdir, *unarc, *pwd, *lname, *fileid;
char Desc[256], TDesc[256]; char Desc[256], TDesc[256];
int IsArchive = FALSE, MustRearc = FALSE, UnPacked = FALSE; int IsArchive = FALSE, MustRearc = FALSE, UnPacked = FALSE;
int IsVirus = FALSE, File_Id = FALSE; int IsVirus = FALSE, File_Id = FALSE;
@ -156,15 +156,17 @@ void AdoptFile(int Area, char *File, char *Description)
/* /*
* Try to get a FILE_ID.DIZ * Try to get a FILE_ID.DIZ
*/ */
snprintf(temp, PATH_MAX, "%s/tmp/arc%d/FILE_ID.DIZ", getenv("MBSE_ROOT"), (int)getpid()); fileid = calloc(PATH_MAX, sizeof(char));
snprintf(temp2, PATH_MAX, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid());
if (file_cp(temp, temp2) == 0) { snprintf(fileid, PATH_MAX, "FILE_ID.DIZ");
File_Id = TRUE; if (getfilecase(temp, fileid)) {
} else { snprintf(temp, PATH_MAX, "%s/tmp/arc%d/%s", getenv("MBSE_ROOT"), (int)getpid(), fileid);
snprintf(temp, PATH_MAX, "%s/tmp/arc%d/file_id.diz", getenv("MBSE_ROOT"), (int)getpid()); snprintf(temp2, PATH_MAX, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
if (file_cp(temp, temp2) == 0) if (file_cp(temp, temp2) == 0) {
File_Id = TRUE; File_Id = TRUE;
}
} }
free(fileid);
if (File_Id) { if (File_Id) {
Syslog('f', "FILE_ID.DIZ found"); Syslog('f', "FILE_ID.DIZ found");

View File

@ -4,7 +4,7 @@
* Purpose: File Database Maintenance - utilities * Purpose: File Database Maintenance - utilities
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -222,26 +222,17 @@ int UnpackFile(char *File)
* Check if there is a temp directory to unpack the archive. * Check if there is a temp directory to unpack the archive.
*/ */
if (create_tmpwork()) { if (create_tmpwork()) {
snprintf(temp, PATH_MAX, "%s/tmp/arc", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid());
if (!do_quiet) if (!do_quiet)
printf("\nCan't create %s\n", temp); printf("\nCan't create %s\n", temp);
die(MBERR_GENERAL); die(MBERR_GENERAL);
} }
/*
* Check for stale FILE_ID.DIZ files
*/
snprintf(temp, PATH_MAX, "%s/tmp/arc%d/FILE_ID.DIZ", getenv("MBSE_ROOT"), (int)getpid());
if (!unlink(temp))
Syslog('+', "Removed stale %s", temp);
snprintf(temp, PATH_MAX, "%s/tmp/arc%d/file_id.diz", getenv("MBSE_ROOT"), (int)getpid());
if (!unlink(temp))
Syslog('+', "Removed stale %s", temp);
if (!getarchiver(unarc)) { if (!getarchiver(unarc)) {
WriteError("No archiver available for %s", File); WriteError("No archiver available for %s", File);
if (!do_quiet) if (!do_quiet)
printf("\nNo archiver available for %s\n", File); printf("\nNo archiver available for %s\n", File);
clean_tmpwork();
return FALSE; return FALSE;
} }
@ -250,12 +241,14 @@ int UnpackFile(char *File)
WriteError("No unarc command available"); WriteError("No unarc command available");
if (!do_quiet) if (!do_quiet)
printf("\nNo unarc command available\n"); printf("\nNo unarc command available\n");
clean_tmpwork();
return FALSE; return FALSE;
} }
snprintf(temp, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid()); snprintf(temp, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid());
if (chdir(temp) != 0) { if (chdir(temp) != 0) {
WriteError("$Can't change to %s", temp); WriteError("$Can't change to %s", temp);
clean_tmpwork();
die(MBERR_GENERAL); die(MBERR_GENERAL);
} }
@ -265,11 +258,11 @@ int UnpackFile(char *File)
free(pwd); free(pwd);
free(cmd); free(cmd);
return TRUE; return TRUE;
} else {
chdir(pwd);
WriteError("Unpack error, file may be corrupt");
clean_tmpwork();
} }
chdir(pwd);
WriteError("Unpack error, file may be corrupt");
clean_tmpwork();
return FALSE; return FALSE;
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Process 1 .tic file * Purpose ...............: Process 1 .tic file
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -376,23 +376,6 @@ int ProcessTic(fa_list **sbl, orphans **opl)
if ((tic.VirScan || MustRearc) && IsArchive) { if ((tic.VirScan || MustRearc) && IsArchive) {
snprintf(temp2, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid()); snprintf(temp2, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid());
/*
* Check for stale FILE_ID.DIZ files
*/
// snprintf(temp1, PATH_MAX, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
// if (!unlink(temp1))
// Syslog('+', "Removed stale %s", temp1);
// snprintf(temp1, PATH_MAX, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
// if (!unlink(temp1))
// Syslog('+', "Removed stale %s", temp1);
// snprintf(temp1, PATH_MAX, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
// if (!unlink(temp1))
// Syslog('+', "Removed stale %s", temp1);
// snprintf(temp1, PATH_MAX, "%s/tmp/file_id.diz", getenv("MBSE_ROOT"));
// if (!unlink(temp1))
// Syslog('+', "Removed stale %s", temp1);
if (!checkspace(temp2, TIC.TicIn.File, UNPACK_FACTOR)) { if (!checkspace(temp2, TIC.TicIn.File, UNPACK_FACTOR)) {
Bad((char *)"Not enough free diskspace left"); Bad((char *)"Not enough free diskspace left");
free(Temp); free(Temp);
@ -490,15 +473,17 @@ int ProcessTic(fa_list **sbl, orphans **opl)
if (tic.FileId && tic.FileArea && IsArchive) { if (tic.FileId && tic.FileArea && IsArchive) {
if (UnPacked) { if (UnPacked) {
snprintf(temp1, PATH_MAX, "%s/tmp/arc%d/FILE_ID.DIZ", getenv("MBSE_ROOT"), (int)getpid()); snprintf(temp1, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid());
snprintf(temp2, PATH_MAX, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT")); snprintf(Temp, PATH_MAX, "FILE_ID.DIZ");
if (file_cp(temp1, temp2) == 0) { if (getfilecase(temp1, Temp)) {
File_Id = TRUE; Syslog('f', "Found %s", Temp);
} else { snprintf(temp1, PATH_MAX, "%s/tmp/arc%d/%s", getenv("MBSE_ROOT"), (int)getpid(), Temp);
snprintf(temp1, PATH_MAX, "%s/tmp/arc%d/file_id.diz", getenv("MBSE_ROOT"), (int)getpid()); snprintf(temp2, PATH_MAX, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
if (file_cp(temp1, temp2) == 0) { if (file_cp(temp1, temp2) == 0) {
File_Id = TRUE; File_Id = TRUE;
} }
} else {
Syslog('f', "Didn't find a FILE_ID.DIZ");
} }
} else { } else {
if (!getarchiver(unarc)) { if (!getarchiver(unarc)) {