mirror of
https://github.com/anope/anope.git
synced 2026-07-10 16:43:13 +02:00
BUILD : 1.7.19 (1289) BUGS : 768 NOTES : Fixed module runtime directory not always being cleaned up nicely
git-svn-id: svn://svn.anope.org/anope/trunk@1289 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1007 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
parent
56800d4103
commit
3c1a2fbfca
+92
-12
@@ -626,20 +626,20 @@ int loadModule(Module * m, User * u)
|
||||
return MOD_ERR_NOLOAD;
|
||||
}
|
||||
if (func) {
|
||||
version = (int (*)())ano_modsym(m->handle,"getAnopeBuildVersion");
|
||||
if (version) {
|
||||
if (version() >= VERSION_BUILD ) {
|
||||
if(debug) {
|
||||
alog("Module %s compiled against current or newer anope revision %d, this is %d",m->name,version(),VERSION_BUILD);
|
||||
}
|
||||
} else {
|
||||
version = (int (*)())ano_modsym(m->handle,"getAnopeBuildVersion");
|
||||
if (version) {
|
||||
if (version() >= VERSION_BUILD ) {
|
||||
if(debug) {
|
||||
alog("Module %s compiled against current or newer anope revision %d, this is %d",m->name,version(),VERSION_BUILD);
|
||||
}
|
||||
} else {
|
||||
alog("Module %s is compiled against an old version of anope (%d) current is %d", m->name, version(), VERSION_BUILD);
|
||||
alog("Rebuild module %s against the current version to resolve this error", m->name);
|
||||
ano_modclose(m->handle);
|
||||
ano_modclearerr();
|
||||
return MOD_ERR_NOLOAD;
|
||||
}
|
||||
} else {
|
||||
ano_modclose(m->handle);
|
||||
ano_modclearerr();
|
||||
return MOD_ERR_NOLOAD;
|
||||
}
|
||||
} else {
|
||||
ano_modclose(m->handle);
|
||||
ano_modclearerr();
|
||||
alog("Module %s is compiled against an older version of anope (unknown)", m->name);
|
||||
@@ -2788,4 +2788,84 @@ void handleModuleOperationQueue(void)
|
||||
mod_current_user = NULL;
|
||||
}
|
||||
|
||||
void ModuleRunTimeDirCleanUp(void)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
#else
|
||||
BOOL fFinished;
|
||||
HANDLE hList;
|
||||
TCHAR szDir[MAX_PATH + 1];
|
||||
TCHAR szSubDir[MAX_PATH + 1];
|
||||
WIN32_FIND_DATA FileData;
|
||||
char buffer[_MAX_PATH];
|
||||
#endif
|
||||
char dirbuf[BUFSIZE];
|
||||
char filebuf[BUFSIZE];
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
snprintf(dirbuf, BUFSIZE, "%s/modules/runtime", services_dir);
|
||||
#else
|
||||
snprintf(dirbuf, BUFSIZE, "\\%s", "modules/runtime");
|
||||
#endif
|
||||
|
||||
if (debug) {
|
||||
alog("debug: Cleaning out Module run time directory (%s) - this may take a moment please wait", dirbuf);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
if ((dirp = opendir(dirbuf)) == NULL) {
|
||||
if (debug) {
|
||||
alog("debug: cannot open directory (%s)", dirbuf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
if (dp->d_ino == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!stricmp(dp->d_name, ".") || !stricmp(dp->d_name, "..")) {
|
||||
continue;
|
||||
}
|
||||
snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, dp->d_name);
|
||||
unlink(filebuf);
|
||||
}
|
||||
closedir(dirp);
|
||||
#else
|
||||
/* Get the current working directory: */
|
||||
if (_getcwd(buffer, _MAX_PATH) == NULL) {
|
||||
if (debug) {
|
||||
alog("debug: Unable to set Current working directory");
|
||||
}
|
||||
}
|
||||
snprintf(szDir, sizeof(szDir), "%s\\%s\\*", buffer, dirname);
|
||||
|
||||
hList = FindFirstFile(szDir, &FileData);
|
||||
if (hList != INVALID_HANDLE_VALUE) {
|
||||
fFinished = FALSE;
|
||||
while (!fFinished) {
|
||||
if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, FileData.cFileName);
|
||||
DeleteFile(filebuf);
|
||||
}
|
||||
if (!FindNextFile(hList, &FileData)) {
|
||||
if (GetLastError() == ERROR_NO_MORE_FILES) {
|
||||
fFinished = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (debug) {
|
||||
alog("debug: Invalid File Handle. GetLastError reports %d\n", GetLastError());
|
||||
}
|
||||
}
|
||||
FindClose(hList);
|
||||
#endif
|
||||
if (debug) {
|
||||
alog("debug: Module run time directory has been cleaned out");
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
||||
Reference in New Issue
Block a user