Preserving filerecord when filename exists
This commit is contained in:
parent
2dc28fdc07
commit
0e78ebf32b
@ -44,6 +44,8 @@ v0.35.03 06-Jul-2002
|
|||||||
Rewrote the outbound queue system, the queue now works for
|
Rewrote the outbound queue system, the queue now works for
|
||||||
files also.
|
files also.
|
||||||
Removed debug logline with extract of FILE_ID.DIZ.
|
Removed debug logline with extract of FILE_ID.DIZ.
|
||||||
|
When a file is imported with a name that is already present,
|
||||||
|
the existing filerecord is updated and not replaced.
|
||||||
|
|
||||||
newuser:
|
newuser:
|
||||||
Check for Unix accounts is now case sensitive.
|
Check for Unix accounts is now case sensitive.
|
||||||
|
5
TODO
5
TODO
@ -92,6 +92,11 @@ mbfile:
|
|||||||
|
|
||||||
N: Override timeout during virus scan when files are imported.
|
N: Override timeout during virus scan when files are imported.
|
||||||
|
|
||||||
|
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
|
||||||
|
areas.
|
||||||
|
|
||||||
mbaff:
|
mbaff:
|
||||||
L: Add setup parameters for minimum length of keywords.
|
L: Add setup parameters for minimum length of keywords.
|
||||||
|
|
||||||
|
@ -62,12 +62,62 @@ int Add_BBS()
|
|||||||
int Keep = 0, DidDelete = FALSE;
|
int Keep = 0, DidDelete = FALSE;
|
||||||
fd_list *fdl = NULL;
|
fd_list *fdl = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First create 8.3 filename
|
||||||
|
*/
|
||||||
|
sprintf(temp1, "%s", TIC.NewName);
|
||||||
|
name_mangle(temp1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First check for an existing record with the same filename,
|
||||||
|
* if it exists, update the record and we are ready. This will
|
||||||
|
* prevent for example allfiles.zip to get a new record everytime
|
||||||
|
* and thus the download counters will be reset after a new update.
|
||||||
|
*/
|
||||||
|
sprintf(fdbname, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), tic.FileArea);
|
||||||
|
if ((fdb = fopen(fdbname, "r+")) != NULL) {
|
||||||
|
while (fread(&frec, sizeof(frec), 1, fdb) == 1) {
|
||||||
|
if ((strcmp(frec.Name, temp1) == 0) && (strcmp(frec.LName, TIC.NewName) == 0)) {
|
||||||
|
Syslog('f', "Found existing fdb record, will update this one");
|
||||||
|
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
|
||||||
|
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
|
||||||
|
mkdirs(temp2, 0755);
|
||||||
|
if ((rc = file_cp(temp1, temp2))) {
|
||||||
|
WriteError("Copy to %s failed: %s", temp2, strerror(rc));
|
||||||
|
fclose(fdb);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
chmod(temp2, 0644);
|
||||||
|
frec.TicAreaCRC = StringCRC32(TIC.TicIn.Area);
|
||||||
|
frec.Size = TIC.FileSize;
|
||||||
|
frec.Crc32 = TIC.Crc_Int;
|
||||||
|
frec.Announced = TRUE;
|
||||||
|
frec.FileDate = TIC.FileDate;
|
||||||
|
frec.UploadDate = time(NULL);
|
||||||
|
for (i = 0; i <= TIC.File_Id_Ct; i++) {
|
||||||
|
strcpy(frec.Desc[i], TIC.File_Id[i]);
|
||||||
|
if (i == 24)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (strlen(TIC.TicIn.Magic))
|
||||||
|
sprintf(frec.Desc[i], "Magic Request: %s", TIC.TicIn.Magic);
|
||||||
|
fseek(fdb, 0 - sizeof(frec), SEEK_CUR);
|
||||||
|
fwrite(&frec, sizeof(frec), 1, fdb);
|
||||||
|
fclose(fdb);
|
||||||
|
tic_imp++;
|
||||||
|
if ((i = file_rm(temp1)))
|
||||||
|
WriteError("file_rm(%s): %s", temp1, strerror(i));
|
||||||
|
Syslog('f', "Update done");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fdb);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create filedatabase record.
|
* Create filedatabase record.
|
||||||
*/
|
*/
|
||||||
memset(&frec, 0, sizeof(frec));
|
memset(&frec, 0, sizeof(frec));
|
||||||
sprintf(temp1, "%s", TIC.NewName);
|
|
||||||
name_mangle(temp1);
|
|
||||||
strcpy(frec.Name, temp1);
|
strcpy(frec.Name, temp1);
|
||||||
strcpy(frec.LName, TIC.NewName);
|
strcpy(frec.LName, TIC.NewName);
|
||||||
frec.TicAreaCRC = StringCRC32(TIC.TicIn.Area);
|
frec.TicAreaCRC = StringCRC32(TIC.TicIn.Area);
|
||||||
@ -95,7 +145,6 @@ int Add_BBS()
|
|||||||
}
|
}
|
||||||
chmod(temp2, 0644);
|
chmod(temp2, 0644);
|
||||||
|
|
||||||
sprintf(fdbname, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), tic.FileArea);
|
|
||||||
sprintf(fdbtemp, "%s/fdb/fdb%ld.temp", getenv("MBSE_ROOT"), tic.FileArea);
|
sprintf(fdbtemp, "%s/fdb/fdb%ld.temp", getenv("MBSE_ROOT"), tic.FileArea);
|
||||||
|
|
||||||
if ((fdb = fopen(fdbname, "r+")) == NULL) {
|
if ((fdb = fopen(fdbname, "r+")) == NULL) {
|
||||||
@ -136,8 +185,7 @@ int Add_BBS()
|
|||||||
if (strcmp(frec.LName, file.LName) == 0) {
|
if (strcmp(frec.LName, file.LName) == 0) {
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
Insert++;
|
Insert++;
|
||||||
} else
|
} else if (strcmp(frec.LName, file.LName) < 0)
|
||||||
if (strcmp(frec.LName, file.LName) < 0)
|
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
else
|
else
|
||||||
Insert++;
|
Insert++;
|
||||||
@ -219,7 +267,7 @@ int Add_BBS()
|
|||||||
* Delete file from the inbound
|
* Delete file from the inbound
|
||||||
*/
|
*/
|
||||||
if ((i = file_rm(temp1)))
|
if ((i = file_rm(temp1)))
|
||||||
WriteError("$ %d = file_rm(%s)", i, temp1);
|
WriteError("file_rm(%s): %s", temp1, strerror(i));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle the replace option.
|
* Handle the replace option.
|
||||||
@ -234,8 +282,7 @@ int Add_BBS()
|
|||||||
if (strcasecmp(file.LName, TIC.NewName) != 0) {
|
if (strcasecmp(file.LName, TIC.NewName) != 0) {
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
for (i = 0; i < strlen(TIC.NewName); i++) {
|
for (i = 0; i < strlen(TIC.NewName); i++) {
|
||||||
if ((TIC.TicIn.Replace[i] != '?') &&
|
if ((TIC.TicIn.Replace[i] != '?') && (toupper(TIC.TicIn.Replace[i]) != toupper(file.LName[i])))
|
||||||
(toupper(TIC.TicIn.Replace[i]) != toupper(file.LName[i])))
|
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
}
|
}
|
||||||
if (Found) {
|
if (Found) {
|
||||||
|
Reference in New Issue
Block a user