Fixed existing file check for mbfile adopt and import

This commit is contained in:
Michiel Broek 2003-11-15 12:31:05 +00:00
parent f358cb72c8
commit 099601838d
7 changed files with 30 additions and 25 deletions

View File

@ -31,14 +31,15 @@ v0.39.1 22-Oct-2003
mbfile:
When the areanumber with the adopt command was not given, the
help is displayed instead of trying area 0 that doesn't exist.
With the file move command if the file already exists in the
destination area, the move is refused.
With the file move, adopt and import command if the file
already exists in the destination area, the action is refused.
Added mbfile sort <area> command. Files are case insensitive
sorted on the long filename. After sort the indexes are rebuild.
Fixed some logging that should have been debug logging.
mbcico:
Added hydra rpos id -1 indicator for compression stop that
Alex and I agreed to use.
Alex and I agreed to use. A FSP document will be written.
Compression log fixed and added percentage compression.
Added dynamic optimum sendbuffer size with a maximum of 8192
bytes with an average size of 2048 bytes.

2
TODO
View File

@ -126,8 +126,6 @@ mbfile:
L: Possibility to skip file areas from checking and reindexing.
U: With adopt if a file exists there will be troubles.
mbmsg:
N: With the post command if a netmail area is used the netmail area
will cause trouble later, should be blocked to be used on netmail

View File

@ -58,7 +58,7 @@ void AdoptFile(int Area, char *File, char *Description)
int i, j, k, lines = 0, File_id_cnt = 0, rc;
struct FILERecord fdb;
Syslog('-', "Adopt(%d, %s, %s)", Area, MBSE_SS(File), MBSE_SS(Description));
Syslog('f', "Adopt(%d, %s, %s)", Area, MBSE_SS(File), MBSE_SS(Description));
if (!do_quiet)
colour(CYAN, BLACK);
@ -91,7 +91,7 @@ void AdoptFile(int Area, char *File, char *Description)
if ((rc = file_cp(temp, temp2))) {
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
if (!do_quiet)
printf("Can't copy file to %s, %s\n", temp2, strerror(rc));
printf("\nCan't copy file to %s, %s\n", temp2, strerror(rc));
die(MBERR_INIT_ERROR);
} else {
if (do_novir == FALSE) {
@ -108,7 +108,7 @@ void AdoptFile(int Area, char *File, char *Description)
chdir(pwd);
WriteError("Virus found");
if (!do_quiet)
printf("Virus found\n");
printf("\nVirus found\n");
die(MBERR_VIRUS_FOUND);
}
}
@ -135,7 +135,7 @@ void AdoptFile(int Area, char *File, char *Description)
chdir(pwd);
WriteError("Virus found");
if (!do_quiet)
printf("Virus found\n");
printf("\nVirus found\n");
die(MBERR_VIRUS_FOUND);
}
}
@ -166,7 +166,7 @@ void AdoptFile(int Area, char *File, char *Description)
}
if (File_Id) {
Syslog('-', "FILE_ID.DIZ found");
Syslog('f', "FILE_ID.DIZ found");
if ((fp = fopen(temp2, "r"))) {
/*
* Read no more then 25 lines
@ -219,7 +219,7 @@ void AdoptFile(int Area, char *File, char *Description)
if (Description == NULL) {
WriteError("No FILE_ID.DIZ and no description on the commandline");
if (!do_quiet)
printf("No FILE_ID.DIZ and no description on the commandline\n");
printf("\nNo FILE_ID.DIZ and no description on the commandline\n");
DeleteVirusWork();
die(MBERR_COMMANDLINE);
} else {
@ -303,7 +303,7 @@ void AdoptFile(int Area, char *File, char *Description)
} else {
WriteError("Area %d is not available", Area);
if (!do_quiet)
printf("Area %d is not available\n", Area);
printf("\nArea %d is not available\n", Area);
}
if (!do_quiet) {

View File

@ -4,7 +4,7 @@
* Purpose: File Database Maintenance - Import files with files.bbs
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -59,7 +59,7 @@ void ImportFiles(int Area)
struct stat statfile;
struct dirent *de;
Syslog('-', "Import(%d)", Area);
Syslog('f', "Import(%d)", Area);
if (!do_quiet)
colour(CYAN, BLACK);

View File

@ -153,8 +153,6 @@ void Move(int From, int To, char *File)
tothumb = xstrcat(tothumb, fdb.Name);
if (file_exist(topath, F_OK) == 0) {
Syslog('-', "%s", topath);
Syslog('-', "%d", file_exist(topath, F_OK));
WriteError("File %s already exists in area %d", File, To);
if (!do_quiet)
printf("File %s already exists in area %d\n", File, To);

View File

@ -251,7 +251,7 @@ int UnpackFile(char *File)
if (mkdir(temp, 0777)) {
WriteError("$Can't create %s", temp);
if (!do_quiet)
printf("Can't create %s\n", temp);
printf("\nCan't create %s\n", temp);
die(MBERR_GENERAL);
}
}
@ -269,7 +269,7 @@ int UnpackFile(char *File)
if (!getarchiver(unarc)) {
WriteError("No archiver available for %s", File);
if (!do_quiet)
printf("No archiver available for %s\n", File);
printf("\nNo archiver available for %s\n", File);
return FALSE;
}
@ -277,7 +277,7 @@ int UnpackFile(char *File)
if ((cmd == NULL) || (cmd == "")) {
WriteError("No unarc command available");
if (!do_quiet)
printf("No unarc command available\n");
printf("\nNo unarc command available\n");
return FALSE;
}
@ -321,10 +321,18 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath, cha
* 8.3 filename to the long filename.
*/
mkdirs(DestPath, 0775);
if (file_exist(DestPath, F_OK) == 0) {
WriteError("File %s already exists in area %d", fdb.Name, Area);
if (!do_quiet)
printf("\nFile %s already exists in area %d\n", fdb.Name, Area);
return FALSE;
}
if ((rc = file_cp(FromPath, DestPath))) {
WriteError("Can't copy file in place");
if (!do_quiet)
printf("Can't copy file to %s, %s\n", DestPath, strerror(rc));
printf("\nCan't copy file to %s, %s\n", DestPath, strerror(rc));
return FALSE;
}
chmod(DestPath, 0644);
@ -332,7 +340,7 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath, cha
if ((rc = symlink(DestPath, LinkPath))) {
WriteError("Can't create symbolic link %s", LinkPath);
if (!do_quiet)
printf("Can't create symbolic link %s, %s\n", LinkPath, strerror(rc));
printf("\nCan't create symbolic link %s, %s\n", LinkPath, strerror(rc));
unlink(DestPath);
return FALSE;
}
@ -493,7 +501,7 @@ int LoadAreaRec(int Area)
if ((pAreas = fopen (sAreas, "r")) == NULL) {
WriteError("$Can't open %s", sAreas);
if (!do_quiet)
printf("Can't open %s\n", sAreas);
printf("\nCan't open %s\n", sAreas);
return FALSE;
}
@ -501,7 +509,7 @@ int LoadAreaRec(int Area)
if (fseek(pAreas, ((Area - 1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET)) {
WriteError("$Can't seek record %d in %s", Area, sAreas);
if (!do_quiet)
printf("Can't seek record %d in %s\n", Area, sAreas);
printf("\nCan't seek record %d in %s\n", Area, sAreas);
fclose(pAreas);
free(sAreas);
return FALSE;
@ -510,7 +518,7 @@ int LoadAreaRec(int Area)
if (fread(&area, areahdr.recsize, 1, pAreas) != 1) {
WriteError("$Can't read record %d in %s", Area, sAreas);
if (!do_quiet)
printf("Can't read record %d in %s\n", Area, sAreas);
printf("\nCan't read record %d in %s\n", Area, sAreas);
fclose(pAreas);
free(sAreas);
return FALSE;

View File

@ -330,7 +330,7 @@ if [ "$DISTNAME" = "Gentoo" ]; then
DISTINIT="/etc/init.d/mbsebbs"
cp init.Gentoo $DISTINIT
chmod 755 $DISTINIT
update-rc mbsebbs defaults
rc-update add mbsebbs default
echo "Gentoo install ready."
log "+" "Gentoo init script installed"
fi