mirror of
https://github.com/acanas/swad-core.git
synced 2024-07-01 04:45:54 +02:00
Version 15.70.3
This commit is contained in:
parent
c5dddc2eb7
commit
5ef7ba86e8
|
@ -118,12 +118,13 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.70.2 (2015/12/21)"
|
#define Log_PLATFORM_VERSION "SWAD 15.70.3 (2015/12/21)"
|
||||||
#define CSS_FILE "swad15.65.1.css"
|
#define CSS_FILE "swad15.65.1.css"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 15.70.3: Dec 21, 2015 Code refactoring in file browser. (187490 lines)
|
||||||
Version 15.70.2: Dec 21, 2015 Users can selected number of months in form to remove old files in briefcase. Not finished. (187473 lines)
|
Version 15.70.2: Dec 21, 2015 Users can selected number of months in form to remove old files in briefcase. Not finished. (187473 lines)
|
||||||
Version 15.70.1: Dec 21, 2015 Removing old files in briefcase. Not finished. (187408 lines)
|
Version 15.70.1: Dec 21, 2015 Removing old files in briefcase. Not finished. (187408 lines)
|
||||||
Version 15.70: Dec 21, 2015 New action to remove old files in briefcase. Not finished. (187352 lines)
|
Version 15.70: Dec 21, 2015 New action to remove old files in briefcase. Not finished. (187352 lines)
|
||||||
|
|
|
@ -3426,8 +3426,7 @@ static void Brw_WriteTopBeforeShowingFileBrowser (void)
|
||||||
break;
|
break;
|
||||||
case Brw_ADMI_BRIEF_USR:
|
case Brw_ADMI_BRIEF_USR:
|
||||||
if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) // TODO: Remove this line when stable
|
if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) // TODO: Remove this line when stable
|
||||||
if (Gbl.CurrentAct != ActAskRemOldBrf &&
|
if (Gbl.CurrentAct != ActAskRemOldBrf)
|
||||||
Gbl.CurrentAct != ActRemOldBrf)
|
|
||||||
Brw_PutFormToAskRemOldFiles ();
|
Brw_PutFormToAskRemOldFiles ();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -4625,6 +4624,7 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
|
||||||
for (NumFileInThisDir = 0;
|
for (NumFileInThisDir = 0;
|
||||||
NumFileInThisDir < NumFilesInThisDir;
|
NumFileInThisDir < NumFilesInThisDir;
|
||||||
NumFileInThisDir++)
|
NumFileInThisDir++)
|
||||||
|
{
|
||||||
if (strcmp (FileList[NumFileInThisDir]->d_name,".") &&
|
if (strcmp (FileList[NumFileInThisDir]->d_name,".") &&
|
||||||
strcmp (FileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
|
strcmp (FileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
|
||||||
{
|
{
|
||||||
|
@ -4647,6 +4647,9 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
|
||||||
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free (FileList[NumFileInThisDir]);
|
||||||
|
}
|
||||||
|
free (FileList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -11329,52 +11332,34 @@ static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder)
|
||||||
static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
|
static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
|
||||||
time_t TimeRemoveFilesOlder)
|
time_t TimeRemoveFilesOlder)
|
||||||
{
|
{
|
||||||
struct dirent **DirFileList;
|
struct dirent **FileList;
|
||||||
struct dirent **SubdirFileList;
|
|
||||||
int NumFileInThisDir;
|
int NumFileInThisDir;
|
||||||
int NumFilesInThisDir;
|
int NumFilesInThisDir;
|
||||||
int NumFilesInThisSubdir;
|
|
||||||
char PathFileRel[PATH_MAX+1];
|
char PathFileRel[PATH_MAX+1];
|
||||||
struct stat FileStatus;
|
struct stat FileStatus;
|
||||||
|
|
||||||
/***** Scan directory *****/
|
/***** Scan directory *****/
|
||||||
NumFilesInThisDir = scandir (Path,&DirFileList,NULL,alphasort);
|
NumFilesInThisDir = scandir (Path,&FileList,NULL,alphasort);
|
||||||
|
|
||||||
|
if (NumFilesInThisDir > 2)
|
||||||
|
{
|
||||||
/***** Check file by file removing old files *****/
|
/***** Check file by file removing old files *****/
|
||||||
for (NumFileInThisDir = 0;
|
for (NumFileInThisDir = 0;
|
||||||
NumFileInThisDir < NumFilesInThisDir;
|
NumFileInThisDir < NumFilesInThisDir;
|
||||||
NumFileInThisDir++)
|
NumFileInThisDir++)
|
||||||
if (strcmp (DirFileList[NumFileInThisDir]->d_name,".") &&
|
{
|
||||||
strcmp (DirFileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
|
if (strcmp (FileList[NumFileInThisDir]->d_name,".") &&
|
||||||
|
strcmp (FileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
|
||||||
{
|
{
|
||||||
/***** Construct the full path of the file or folder *****/
|
/***** Construct the full path of the file or folder *****/
|
||||||
sprintf (PathFileRel,"%s/%s",Path,DirFileList[NumFileInThisDir]->d_name);
|
sprintf (PathFileRel,"%s/%s",Path,FileList[NumFileInThisDir]->d_name);
|
||||||
|
|
||||||
/***** Get file or folder status *****/
|
/***** Get file or folder status *****/
|
||||||
lstat (PathFileRel,&FileStatus);
|
lstat (PathFileRel,&FileStatus);
|
||||||
|
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
{
|
|
||||||
/***** Check if this subdirectory has files or folders in it *****/
|
|
||||||
NumFilesInThisSubdir = scandir (PathFileRel,&SubdirFileList,NULL,NULL);
|
|
||||||
|
|
||||||
if (NumFilesInThisSubdir > 2) // Not empty directory
|
|
||||||
{
|
|
||||||
/* Scan subtree starting at this this directory recursively */
|
/* Scan subtree starting at this this directory recursively */
|
||||||
Brw_ScanDirRemovingOlfFiles (Level+1,PathFileRel,TimeRemoveFilesOlder);
|
Brw_ScanDirRemovingOlfFiles (Level+1,PathFileRel,TimeRemoveFilesOlder);
|
||||||
|
|
||||||
/* Check again number of files after deletion */
|
|
||||||
NumFilesInThisSubdir = scandir (PathFileRel,&SubdirFileList,NULL,NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NumFilesInThisSubdir <= 2 && // It's an empty folder
|
|
||||||
FileStatus.st_mtime < TimeRemoveFilesOlder) // ..and it's old
|
|
||||||
{
|
|
||||||
/* Remove folder */
|
|
||||||
Lay_ShowAlert (Lay_SUCCESS,PathFileRel);
|
|
||||||
Gbl.FileBrowser.Removed.NumFolders++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (S_ISREG (FileStatus.st_mode) && // It's a regular file
|
else if (S_ISREG (FileStatus.st_mode) && // It's a regular file
|
||||||
FileStatus.st_mtime < TimeRemoveFilesOlder) // ..and it's old
|
FileStatus.st_mtime < TimeRemoveFilesOlder) // ..and it's old
|
||||||
{
|
{
|
||||||
|
@ -11383,4 +11368,36 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
|
||||||
Gbl.FileBrowser.Removed.NumFiles++;
|
Gbl.FileBrowser.Removed.NumFiles++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free (FileList[NumFileInThisDir]);
|
||||||
|
}
|
||||||
|
free (FileList);
|
||||||
|
|
||||||
|
/***** Rescan folder in order to see
|
||||||
|
if it's now empty after deletion *****/
|
||||||
|
if (Level > 1)
|
||||||
|
{
|
||||||
|
/* Count number of files in folder */
|
||||||
|
NumFilesInThisDir = scandir (Path,&FileList,NULL,alphasort);
|
||||||
|
|
||||||
|
/* Free list of files */
|
||||||
|
for (NumFileInThisDir = 0;
|
||||||
|
NumFileInThisDir < NumFilesInThisDir;
|
||||||
|
NumFileInThisDir++)
|
||||||
|
free (FileList[NumFileInThisDir]);
|
||||||
|
free (FileList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Level > 1 && NumFilesInThisDir <= 2) // It's an empty folder inside root folder
|
||||||
|
{
|
||||||
|
/***** Get folder status *****/
|
||||||
|
lstat (Path,&FileStatus);
|
||||||
|
|
||||||
|
if (FileStatus.st_mtime < TimeRemoveFilesOlder)
|
||||||
|
{
|
||||||
|
/* Remove folder */
|
||||||
|
Lay_ShowAlert (Lay_SUCCESS,Path);
|
||||||
|
Gbl.FileBrowser.Removed.NumFolders++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user