mirror of https://github.com/acanas/swad-core.git
Version18.83.1
This commit is contained in:
parent
689227fa44
commit
68f104cbdc
|
@ -459,10 +459,13 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.83 (2019-03-20)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.83.1 (2019-03-20)"
|
||||
#define CSS_FILE "swad18.83.css"
|
||||
#define JS_FILE "swad18.80.js"
|
||||
/*
|
||||
Cfg_PATH_FILE_BROWSER_TMP_PUBLIC crece muy rápido. Tal vez debería organizarse en una jerarquía usando las dos primeras letras
|
||||
|
||||
Version 18.83.1: Mar 20, 2019 Fixed bug in removal of old files in a directory. (240561 lines)
|
||||
Version 18.83: Mar 20, 2019 Important optimization on removing of temporary files to increase speed.
|
||||
Code refactoring related to paths and URL.
|
||||
Fixing in CSS to hide overflow in timeline. (240554 lines)
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
/** Uncomment one of the following installations of SWAD or create your own **/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define LOCALHOST_UBUNTU // Comment this line if not applicable
|
||||
//#define LOCALHOST_UBUNTU // Comment this line if not applicable
|
||||
//#define OPENSWAD_ORG // Comment this line if not applicable
|
||||
//#define SWAD_UGR_ES // Comment this line if not applicable
|
||||
#define SWAD_UGR_ES // Comment this line if not applicable
|
||||
//#define SWADBERRY_UGR_ES // Comment this line if not applicable
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
72
swad_file.c
72
swad_file.c
|
@ -38,6 +38,7 @@
|
|||
#include <unistd.h> // For unlink
|
||||
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_file.h"
|
||||
#include "swad_string.h"
|
||||
|
@ -383,6 +384,8 @@ void Fil_CloseUpdateFile (const char CurrentName[PATH_MAX + 1],
|
|||
|
||||
bool Fil_CheckIfPathExists (const char *Path)
|
||||
{
|
||||
// Important: access with a link returns
|
||||
// if exists the file pointed by the link, not the link itself
|
||||
return access (Path,F_OK) ? false :
|
||||
true;
|
||||
}
|
||||
|
@ -479,7 +482,8 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1])
|
|||
/********************* Remove old temporary directories **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDirectory)
|
||||
void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,
|
||||
bool RemoveDirectory)
|
||||
{
|
||||
struct dirent **FileList;
|
||||
int NumFile;
|
||||
|
@ -489,45 +493,45 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDire
|
|||
|
||||
/***** Check this path (file or directory)
|
||||
because it could have already been deleted *****/
|
||||
if (Fil_CheckIfPathExists (Path))
|
||||
if (!lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||
{
|
||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||
// Important: don't use access here to check if path exists
|
||||
// because access with a link returns if exists
|
||||
// the file pointed by the link, not the link itself
|
||||
if (!lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||
{
|
||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||
{
|
||||
/***** Scan the directory and delete recursively *****/
|
||||
if ((NumFiles = scandir (Path,&FileList,NULL,NULL)) >= 0) // No error
|
||||
{
|
||||
/***** Scan the directory and delete recursively *****/
|
||||
if ((NumFiles = scandir (Path,&FileList,NULL,NULL)) >= 0) // No error
|
||||
/* Loop over files */
|
||||
for (NumFile = 0;
|
||||
NumFile < NumFiles;
|
||||
NumFile++)
|
||||
{
|
||||
/* Loop over files */
|
||||
for (NumFile = 0;
|
||||
NumFile < NumFiles;
|
||||
NumFile++)
|
||||
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||
{
|
||||
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||
{
|
||||
snprintf (Path2,sizeof (Path2),
|
||||
"%s/%s",
|
||||
Path,FileList[NumFile]->d_name);
|
||||
Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call
|
||||
}
|
||||
free ((void *) FileList[NumFile]);
|
||||
snprintf (Path2,sizeof (Path2),
|
||||
"%s/%s",
|
||||
Path,FileList[NumFile]->d_name);
|
||||
Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call
|
||||
}
|
||||
free ((void *) FileList);
|
||||
|
||||
if (RemoveDirectory)
|
||||
/* Remove the directory itself */
|
||||
if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove)
|
||||
rmdir (Path);
|
||||
free ((void *) FileList[NumFile]);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
free ((void *) FileList);
|
||||
|
||||
if (RemoveDirectory)
|
||||
/* Remove the directory itself */
|
||||
if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove)
|
||||
rmdir (Path);
|
||||
}
|
||||
else // Not a directory
|
||||
{
|
||||
if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove)
|
||||
unlink (Path);
|
||||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
}
|
||||
else // Not a directory
|
||||
if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove)
|
||||
unlink (Path);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -80,7 +80,8 @@ bool Fil_CheckIfPathExists (const char *Path);
|
|||
void Fil_CreateDirIfNotExists (const char Path[PATH_MAX + 1]);
|
||||
void Fil_RemoveTree (const char *Path);
|
||||
|
||||
void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDirectory);
|
||||
void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,
|
||||
bool RemoveDirectory);
|
||||
void Fil_FastCopyOfFiles (const char *PathSrc,const char *PathTgt);
|
||||
void Fil_FastCopyOfOpenFiles (FILE *FileSrc,FILE *FileTgt);
|
||||
|
||||
|
|
|
@ -1404,6 +1404,8 @@ void Lay_RefreshNotifsAndConnected (void)
|
|||
Ntf_SendPendingNotifByEMailToAllUsrs (); // Send pending notifications by email
|
||||
else if (!(Gbl.PID % 19))
|
||||
FW_PurgeFirewall (); // Remove old clicks from firewall
|
||||
else if (!(Gbl.PID % 23))
|
||||
Fil_RemoveOldTmpFiles (Cfg_PATH_FILE_BROWSER_TMP_PUBLIC ,Cfg_TIME_TO_DELETE_BROWSER_TMP_FILES ,false); // Remove the oldest temporary public directories used for downloading
|
||||
else if (!(Gbl.PID % 101))
|
||||
Brw_RemoveExpiredExpandedFolders (); // Remove old expanded folders (from all users)
|
||||
else if (!(Gbl.PID % 103))
|
||||
|
@ -1413,18 +1415,16 @@ void Lay_RefreshNotifsAndConnected (void)
|
|||
else if (!(Gbl.PID % 109))
|
||||
Fil_RemoveOldTmpFiles (Cfg_PATH_OUT_PRIVATE ,Cfg_TIME_TO_DELETE_HTML_OUTPUT ,false);
|
||||
else if (!(Gbl.PID % 113))
|
||||
Fil_RemoveOldTmpFiles (Cfg_PATH_FILE_BROWSER_TMP_PUBLIC ,Cfg_TIME_TO_DELETE_BROWSER_TMP_FILES ,false); // Remove the oldest temporary public directories used for downloading
|
||||
else if (!(Gbl.PID % 127))
|
||||
Fil_RemoveOldTmpFiles (Cfg_PATH_PHOTO_TMP_PUBLIC ,Cfg_TIME_TO_DELETE_PHOTOS_TMP_FILES ,false);
|
||||
else if (!(Gbl.PID % 131))
|
||||
else if (!(Gbl.PID % 127))
|
||||
Fil_RemoveOldTmpFiles (Cfg_PATH_PHOTO_TMP_PRIVATE ,Cfg_TIME_TO_DELETE_PHOTOS_TMP_FILES ,false);
|
||||
else if (!(Gbl.PID % 137))
|
||||
else if (!(Gbl.PID % 131))
|
||||
Fil_RemoveOldTmpFiles (Cfg_PATH_MEDIA_TMP_PRIVATE ,Cfg_TIME_TO_DELETE_MEDIA_TMP_FILES ,false);
|
||||
else if (!(Gbl.PID % 139))
|
||||
else if (!(Gbl.PID % 137))
|
||||
Fil_RemoveOldTmpFiles (Cfg_PATH_ZIP_PRIVATE ,Cfg_TIME_TO_DELETE_BROWSER_ZIP_FILES ,false);
|
||||
else if (!(Gbl.PID % 149))
|
||||
else if (!(Gbl.PID % 139))
|
||||
Fil_RemoveOldTmpFiles (Cfg_PATH_MARK_PRIVATE ,Cfg_TIME_TO_DELETE_MARKS_TMP_FILES ,false);
|
||||
else if (!(Gbl.PID % 151))
|
||||
else if (!(Gbl.PID % 149))
|
||||
Fil_RemoveOldTmpFiles (Cfg_PATH_TEST_PRIVATE ,Cfg_TIME_TO_DELETE_TEST_TMP_FILES ,false);
|
||||
|
||||
/***** Send, before the HTML, the refresh time *****/
|
||||
|
|
Loading…
Reference in New Issue