When a filearea was moved to another path the symlinks were forgotten
This commit is contained in:
parent
fcdbbbbd6d
commit
89c7bfe8db
@ -35,6 +35,10 @@ v0.83.13 13-Feb-2006
|
|||||||
Fixed startup problem on new installations.
|
Fixed startup problem on new installations.
|
||||||
Some code cleanup.
|
Some code cleanup.
|
||||||
|
|
||||||
|
mbsetup:
|
||||||
|
When a filearea was moved to another path the symlinks were not
|
||||||
|
moved to the new path.
|
||||||
|
|
||||||
|
|
||||||
v0.83.12 06-Feb-2006 - 13-Feb-2006
|
v0.83.12 06-Feb-2006 - 13-Feb-2006
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: File Setup Program
|
* Purpose ...............: File Setup Program
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2005
|
* Copyright (C) 1997-2006
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -261,210 +261,231 @@ void FileScreen(void)
|
|||||||
*/
|
*/
|
||||||
int EditFileRec(int Area)
|
int EditFileRec(int Area)
|
||||||
{
|
{
|
||||||
FILE *fil;
|
FILE *fil;
|
||||||
char mfile[PATH_MAX], *temp, tpath[65], frpath[81], topath[81];
|
char mfile[PATH_MAX], *temp, tpath[65], frpath[PATH_MAX], topath[PATH_MAX], *lnpath;
|
||||||
int offset;
|
unsigned int crc, crc1;
|
||||||
unsigned int crc, crc1;
|
int Available, files, rc, Force = FALSE, count, offset;
|
||||||
int Available, files, rc, Force = FALSE, count;
|
DIR *dp;
|
||||||
DIR *dp;
|
struct dirent *de;
|
||||||
struct dirent *de;
|
struct stat stb;
|
||||||
struct stat stb;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct FILE_record f_db;
|
||||||
|
|
||||||
clr_index();
|
clr_index();
|
||||||
working(1, 0, 0);
|
working(1, 0, 0);
|
||||||
IsDoing("Edit File Area");
|
IsDoing("Edit File Area");
|
||||||
|
|
||||||
snprintf(mfile, PATH_MAX, "%s/etc/fareas.temp", getenv("MBSE_ROOT"));
|
snprintf(mfile, PATH_MAX, "%s/etc/fareas.temp", getenv("MBSE_ROOT"));
|
||||||
if ((fil = fopen(mfile, "r")) == NULL) {
|
if ((fil = fopen(mfile, "r")) == NULL) {
|
||||||
working(2, 0, 0);
|
working(2, 0, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fread(&areahdr, sizeof(areahdr), 1, fil);
|
fread(&areahdr, sizeof(areahdr), 1, fil);
|
||||||
offset = areahdr.hdrsize + ((Area -1) * areahdr.recsize);
|
offset = areahdr.hdrsize + ((Area -1) * areahdr.recsize);
|
||||||
if (fseek(fil, offset, 0) != 0) {
|
if (fseek(fil, offset, 0) != 0) {
|
||||||
working(2, 0, 0);
|
working(2, 0, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fread(&area, areahdr.recsize, 1, fil);
|
fread(&area, areahdr.recsize, 1, fil);
|
||||||
fclose(fil);
|
fclose(fil);
|
||||||
crc = 0xffffffff;
|
crc = 0xffffffff;
|
||||||
crc = upd_crc32((char *)&area, crc, areahdr.recsize);
|
crc = upd_crc32((char *)&area, crc, areahdr.recsize);
|
||||||
FileScreen();
|
FileScreen();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
set_color(WHITE, BLACK);
|
set_color(WHITE, BLACK);
|
||||||
show_str( 6,16,44, area.Name);
|
show_str( 6,16,44, area.Name);
|
||||||
show_str( 7,16,64, area.Path);
|
show_str( 7,16,64, area.Path);
|
||||||
show_sec( 8,16, area.DLSec);
|
show_sec( 8,16, area.DLSec);
|
||||||
show_sec( 9,16, area.UPSec);
|
show_sec( 9,16, area.UPSec);
|
||||||
show_sec(10,16, area.LTSec);
|
show_sec(10,16, area.LTSec);
|
||||||
show_bool(11,16, area.Available);
|
show_bool(11,16, area.Available);
|
||||||
show_bool(12,16, area.New);
|
show_bool(12,16, area.New);
|
||||||
show_bool(13,16, area.Dupes);
|
show_bool(13,16, area.Dupes);
|
||||||
show_bool(14,16, area.Free);
|
show_bool(14,16, area.Free);
|
||||||
show_bool(15,16, area.DirectDL);
|
show_bool(15,16, area.DirectDL);
|
||||||
show_bool(16,16, area.PwdUP);
|
show_bool(16,16, area.PwdUP);
|
||||||
show_bool(17,16, area.FileFind);
|
show_bool(17,16, area.FileFind);
|
||||||
|
|
||||||
show_bool(12,44, area.AddAlpha);
|
show_bool(12,44, area.AddAlpha);
|
||||||
show_bool(13,44, area.FileReq);
|
show_bool(13,44, area.FileReq);
|
||||||
show_str(14,44,12, area.BbsGroup);
|
show_str(14,44,12, area.BbsGroup);
|
||||||
show_str(15,44,12, area.NewGroup);
|
show_str(15,44,12, area.NewGroup);
|
||||||
show_int(16,44, area.Age);
|
show_int(16,44, area.Age);
|
||||||
show_str(17,44,20, (char *)"********************");
|
show_str(17,44,20, (char *)"********************");
|
||||||
|
|
||||||
show_int(12,73, area.DLdays);
|
show_int(12,73, area.DLdays);
|
||||||
show_int(13,73, area.FDdays);
|
show_int(13,73, area.FDdays);
|
||||||
show_int(14,73, area.MoveArea);
|
show_int(14,73, area.MoveArea);
|
||||||
show_str(15,73, 5, area.Archiver);
|
show_str(15,73, 5, area.Archiver);
|
||||||
show_int(16,73, area.Upload);
|
show_int(16,73, area.Upload);
|
||||||
|
|
||||||
switch(select_menu(23)) {
|
switch(select_menu(23)) {
|
||||||
case 0: crc1 = 0xffffffff;
|
case 0: crc1 = 0xffffffff;
|
||||||
crc1 = upd_crc32((char *)&area, crc1, areahdr.recsize);
|
crc1 = upd_crc32((char *)&area, crc1, areahdr.recsize);
|
||||||
if (crc != crc1) {
|
if (crc != crc1) {
|
||||||
if (Force || yes_no((char *)"Record is changed, save") == 1) {
|
if (Force || yes_no((char *)"Record is changed, save") == 1) {
|
||||||
working(1, 0, 0);
|
working(1, 0, 0);
|
||||||
if ((fil = fopen(mfile, "r+")) == NULL) {
|
if ((fil = fopen(mfile, "r+")) == NULL) {
|
||||||
working(2, 0, 0);
|
working(2, 0, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fseek(fil, offset, 0);
|
fseek(fil, offset, 0);
|
||||||
fwrite(&area, areahdr.recsize, 1, fil);
|
fwrite(&area, areahdr.recsize, 1, fil);
|
||||||
fclose(fil);
|
fclose(fil);
|
||||||
FileUpdated = 1;
|
FileUpdated = 1;
|
||||||
Syslog('+', "Updated file area %d", Area);
|
Syslog('+', "Updated file area %d", Area);
|
||||||
working(6, 0, 0);
|
working(6, 0, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
IsDoing("Browsing Menu");
|
}
|
||||||
return 0;
|
IsDoing("Browsing Menu");
|
||||||
case 1: E_STR( 6,16,44, area.Name, "The ^name^ for this area")
|
return 0;
|
||||||
case 2: strcpy(tpath, area.Path);
|
case 1: E_STR( 6,16,44, area.Name, "The ^name^ for this area")
|
||||||
strcpy(area.Path, edit_pth(7,16,64, area.Path, (char *)"The ^path^ for the files in this area", 0775));
|
case 2: strcpy(tpath, area.Path);
|
||||||
if (strlen(tpath) && strlen(area.Path) && strcmp(tpath, area.Path) && strcmp(tpath, CFG.ftp_base)) {
|
strcpy(area.Path, edit_pth(7,16,64, area.Path, (char *)"The ^path^ for the files in this area", 0775));
|
||||||
if ((dp = opendir(tpath)) == NULL) {
|
if (strlen(tpath) && strlen(area.Path) && strcmp(tpath, area.Path) && strcmp(tpath, CFG.ftp_base)) {
|
||||||
WriteError("Can't open directory %s", tpath);
|
if ((dp = opendir(tpath)) == NULL) {
|
||||||
} else {
|
WriteError("Can't open directory %s", tpath);
|
||||||
working(5, 0, 0);
|
} else {
|
||||||
count = 0;
|
working(5, 0, 0);
|
||||||
Syslog('+', "Moving files from %s to %s", tpath, area.Path);
|
count = 0;
|
||||||
while ((de = readdir(dp))) {
|
Syslog('+', "Moving files from %s to %s", tpath, area.Path);
|
||||||
snprintf(frpath, 81, "%s/%s", tpath, de->d_name);
|
lnpath = calloc(PATH_MAX, sizeof(char));
|
||||||
snprintf(topath, 81, "%s/%s", area.Path, de->d_name);
|
while ((de = readdir(dp))) {
|
||||||
if (stat(frpath, &stb) == 0) {
|
snprintf(frpath, PATH_MAX, "%s/%s", tpath, de->d_name);
|
||||||
if (S_ISREG(stb.st_mode)) {
|
snprintf(topath, PATH_MAX, "%s/%s", area.Path, de->d_name);
|
||||||
rc = file_mv(frpath, topath);
|
if (lstat(frpath, &stb) == 0) {
|
||||||
if (rc)
|
if (S_ISREG(stb.st_mode)) {
|
||||||
WriteError("mv %s to %s rc=%d", frpath, topath, rc);
|
/*
|
||||||
else
|
* The real files, also files.bbs, index.html etc.
|
||||||
count++;
|
*/
|
||||||
Nopper();
|
rc = file_mv(frpath, topath);
|
||||||
|
if (rc)
|
||||||
|
WriteError("mv %s to %s rc=%d", frpath, topath, rc);
|
||||||
|
else
|
||||||
|
count++;
|
||||||
|
Nopper();
|
||||||
|
}
|
||||||
|
if (S_ISLNK(stb.st_mode)) {
|
||||||
|
/*
|
||||||
|
* The linked LFN
|
||||||
|
*/
|
||||||
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
||||||
|
while (fread(&f_db, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
|
if (strcmp(f_db.LName, de->d_name) == 0) {
|
||||||
|
/*
|
||||||
|
* Got the symlink to the LFN
|
||||||
|
*/
|
||||||
|
unlink(frpath);
|
||||||
|
snprintf(lnpath, PATH_MAX, "%s/%s", area.Path, f_db.Name);
|
||||||
|
if (symlink(lnpath, topath)) {
|
||||||
|
WriteError("$symlink(%s, %s)", lnpath, topath);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mbsedb_CloseFDB(fdb_area);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dp);
|
|
||||||
if ((rc = rmdir(tpath)))
|
|
||||||
WriteError("rmdir %s rc=%d", tpath, rc);
|
|
||||||
Force = TRUE;
|
|
||||||
FileForced = TRUE;
|
|
||||||
Syslog('+', "Moved %d files", count);
|
|
||||||
}
|
}
|
||||||
|
closedir(dp);
|
||||||
|
free(lnpath);
|
||||||
|
if ((rc = rmdir(tpath)))
|
||||||
|
WriteError("rmdir %s rc=%d", tpath, rc);
|
||||||
|
Force = TRUE;
|
||||||
|
FileForced = TRUE;
|
||||||
|
Syslog('+', "Moved %d files", count);
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case 3: E_SEC( 8,16, area.DLSec, "8.4.3 DOWNLOAD SECURITY", FileScreen)
|
break;
|
||||||
case 4: E_SEC( 9,16, area.UPSec, "8.4.4 UPLOAD SECURITY", FileScreen)
|
case 3: E_SEC( 8,16, area.DLSec, "8.4.3 DOWNLOAD SECURITY", FileScreen)
|
||||||
case 5: E_SEC( 10,16, area.LTSec, "8.4.5 LIST SECURITY", FileScreen)
|
case 4: E_SEC( 9,16, area.UPSec, "8.4.4 UPLOAD SECURITY", FileScreen)
|
||||||
case 6: Available = edit_bool(11, 16, area.Available, (char *)"Is this area ^available^");
|
case 5: E_SEC( 10,16, area.LTSec, "8.4.5 LIST SECURITY", FileScreen)
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
case 6: Available = edit_bool(11, 16, area.Available, (char *)"Is this area ^available^");
|
||||||
snprintf(temp, PATH_MAX, "%s/var/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
if (area.Available && !Available) {
|
snprintf(temp, PATH_MAX, "%s/var/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
||||||
|
if (area.Available && !Available) {
|
||||||
|
/*
|
||||||
|
* Attempt to disable this area, but check first.
|
||||||
|
*/
|
||||||
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
||||||
|
fseek(fdb_area->fp, 0, SEEK_END);
|
||||||
|
files = ((ftell(fdb_area->fp) - fdbhdr.hdrsize) / fdbhdr.recsize);
|
||||||
|
if (files) {
|
||||||
|
errmsg("There are stil %d files in this area", files);
|
||||||
|
Available = TRUE;
|
||||||
|
}
|
||||||
|
mbsedb_CloseFDB(fdb_area);
|
||||||
|
}
|
||||||
|
if (!Available) {
|
||||||
|
if (yes_no((char *)"Are you sure you want to delete this area") == 0)
|
||||||
|
Available = TRUE;
|
||||||
|
}
|
||||||
|
if (!Available) {
|
||||||
/*
|
/*
|
||||||
* Attempt to disable this area, but check first.
|
* Make it so
|
||||||
*/
|
*/
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
unlink(temp);
|
||||||
fseek(fdb_area->fp, 0, SEEK_END);
|
if (strlen(area.Path) && strcmp(area.Path, CFG.ftp_base)) {
|
||||||
files = ((ftell(fdb_area->fp) - fdbhdr.hdrsize) / fdbhdr.recsize);
|
/*
|
||||||
if (files) {
|
* Erase file in path if path is set and not the default
|
||||||
errmsg("There are stil %d files in this area", files);
|
* FTP base path
|
||||||
Available = TRUE;
|
*/
|
||||||
}
|
snprintf(temp, PATH_MAX, "-rf %s", area.Path);
|
||||||
mbsedb_CloseFDB(fdb_area);
|
execute_pth((char *)"rm", temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
}
|
rmdir(area.Path);
|
||||||
if (!Available) {
|
|
||||||
if (yes_no((char *)"Are you sure you want to delete this area") == 0)
|
|
||||||
Available = TRUE;
|
|
||||||
}
|
|
||||||
if (!Available) {
|
|
||||||
/*
|
|
||||||
* Make it so
|
|
||||||
*/
|
|
||||||
unlink(temp);
|
|
||||||
if (strlen(area.Path) && strcmp(area.Path, CFG.ftp_base)) {
|
|
||||||
/*
|
|
||||||
* Erase file in path if path is set and not the default
|
|
||||||
* FTP base path
|
|
||||||
*/
|
|
||||||
snprintf(temp, PATH_MAX, "-rf %s", area.Path);
|
|
||||||
execute_pth((char *)"rm", temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
|
||||||
rmdir(area.Path);
|
|
||||||
}
|
|
||||||
memset(&area, 0, sizeof(area));
|
|
||||||
/*
|
|
||||||
* Fill in default values
|
|
||||||
*/
|
|
||||||
area.New = TRUE;
|
|
||||||
area.Dupes = TRUE;
|
|
||||||
area.FileFind = TRUE;
|
|
||||||
area.AddAlpha = TRUE;
|
|
||||||
area.FileReq = TRUE;
|
|
||||||
strcpy(area.Path, CFG.ftp_base);
|
|
||||||
Syslog('+', "Removed file area %d", Area);
|
|
||||||
}
|
|
||||||
area.Available = Available;
|
|
||||||
FileScreen();
|
|
||||||
}
|
|
||||||
if (!area.Available && Available) {
|
|
||||||
area.Available = TRUE;
|
|
||||||
Syslog('-', "open");
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
|
||||||
Syslog('-', "is open");
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
|
||||||
Syslog('-', "closed");
|
|
||||||
} else {
|
|
||||||
Syslog('-', "failed to open");
|
|
||||||
}
|
}
|
||||||
|
memset(&area, 0, sizeof(area));
|
||||||
|
/*
|
||||||
|
* Fill in default values
|
||||||
|
*/
|
||||||
|
area.New = TRUE;
|
||||||
|
area.Dupes = TRUE;
|
||||||
|
area.FileFind = TRUE;
|
||||||
|
area.AddAlpha = TRUE;
|
||||||
|
area.FileReq = TRUE;
|
||||||
|
strcpy(area.Path, CFG.ftp_base);
|
||||||
|
Syslog('+', "Removed file area %d", Area);
|
||||||
}
|
}
|
||||||
free(temp);
|
area.Available = Available;
|
||||||
break;
|
FileScreen();
|
||||||
case 7: E_BOOL(12,16, area.New, "Include this area in ^new files^ check")
|
}
|
||||||
case 8: E_BOOL(13,16, area.Dupes, "Check this area for ^duplicates^ during upload")
|
if (!area.Available && Available) {
|
||||||
case 9: E_BOOL(14,16, area.Free, "Are all files ^free^ in this area")
|
area.Available = TRUE;
|
||||||
case 10:E_BOOL(15,16, area.DirectDL, "Allow ^direct download^ from this area")
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
||||||
case 11:E_BOOL(16,16, area.PwdUP, "Allow ^password^ on uploads")
|
mbsedb_CloseFDB(fdb_area);
|
||||||
case 12:E_BOOL(17,16, area.FileFind, "Search this area for ^filefind^ requests")
|
}
|
||||||
case 13:E_BOOL(12,44, area.AddAlpha, "Add new files ^alphabetic^ or at the end")
|
}
|
||||||
case 14:E_BOOL(13,44, area.FileReq, "Allow ^file requests^ from this area")
|
free(temp);
|
||||||
case 15:strcpy(area.BbsGroup, PickFGroup((char *)"8.4.15"));
|
break;
|
||||||
FileScreen();
|
case 7: E_BOOL(12,16, area.New, "Include this area in ^new files^ check")
|
||||||
break;
|
case 8: E_BOOL(13,16, area.Dupes, "Check this area for ^duplicates^ during upload")
|
||||||
case 16:strcpy(area.NewGroup, PickNGroup((char *)"8.4.16"));
|
case 9: E_BOOL(14,16, area.Free, "Are all files ^free^ in this area")
|
||||||
FileScreen();
|
case 10:E_BOOL(15,16, area.DirectDL, "Allow ^direct download^ from this area")
|
||||||
break;
|
case 11:E_BOOL(16,16, area.PwdUP, "Allow ^password^ on uploads")
|
||||||
case 17:E_INT( 16,44, area.Age, "The ^minimum age^ to access this area")
|
case 12:E_BOOL(17,16, area.FileFind, "Search this area for ^filefind^ requests")
|
||||||
case 18:E_STR( 17,44,20, area.Password, "The ^password^ to access this area")
|
case 13:E_BOOL(12,44, area.AddAlpha, "Add new files ^alphabetic^ or at the end")
|
||||||
case 19:E_INT( 12,73, area.DLdays, "The not ^downloaded days^ to move/kill files")
|
case 14:E_BOOL(13,44, area.FileReq, "Allow ^file requests^ from this area")
|
||||||
case 20:E_INT( 13,73, area.FDdays, "The ^file age^ in days to move/kill files")
|
case 15:strcpy(area.BbsGroup, PickFGroup((char *)"8.4.15"));
|
||||||
case 21:E_INT( 14,73, area.MoveArea, "The ^area to move^ files to, 0 is kill")
|
FileScreen();
|
||||||
case 22:strcpy(area.Archiver, PickArchive((char *)"8.4"));
|
break;
|
||||||
FileScreen();
|
case 16:strcpy(area.NewGroup, PickNGroup((char *)"8.4.16"));
|
||||||
break;
|
FileScreen();
|
||||||
case 23:E_INT( 16,73, area.Upload, "The ^upload^ area, 0 if upload in this area")
|
break;
|
||||||
}
|
case 17:E_INT( 16,44, area.Age, "The ^minimum age^ to access this area")
|
||||||
|
case 18:E_STR( 17,44,20, area.Password, "The ^password^ to access this area")
|
||||||
|
case 19:E_INT( 12,73, area.DLdays, "The not ^downloaded days^ to move/kill files")
|
||||||
|
case 20:E_INT( 13,73, area.FDdays, "The ^file age^ in days to move/kill files")
|
||||||
|
case 21:E_INT( 14,73, area.MoveArea, "The ^area to move^ files to, 0 is kill")
|
||||||
|
case 22:strcpy(area.Archiver, PickArchive((char *)"8.4"));
|
||||||
|
FileScreen();
|
||||||
|
break;
|
||||||
|
case 23:E_INT( 16,73, area.Upload, "The ^upload^ area, 0 if upload in this area")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user