Version 15.70.7

This commit is contained in:
Antonio Cañas Vargas 2015-12-21 14:43:52 +01:00
parent 2db2810842
commit ac3be0464d
4 changed files with 71 additions and 63 deletions

View File

@ -118,12 +118,13 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.70.6 (2015/12/21)"
#define Log_PLATFORM_VERSION "SWAD 15.70.7 (2015/12/21)"
#define CSS_FILE "swad15.65.1.css"
// 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
/*
Version 15.70.7: Dec 21, 2015 Code refactoring in file browser. (187614 lines)
Version 15.70.6: Dec 21, 2015 Removing old files in briefcase. Not finished. (187604 lines)
2 changes necessary in database:
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1488','es','N','Solicitar eliminar archivos antiguos maletín');

View File

@ -11428,9 +11428,9 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
else if (S_ISREG (FileStatus.st_mode) && // It's a regular file
FileStatus.st_mtime < TimeRemoveFilesOlder) // ..and it's old
{
/* Remove file */
// if (unlink (PathFileRel))
// Lay_ShowErrorAndExit ("Can not remove file / link.");
/* Remove file / link */
if (unlink (PathFileRel))
Lay_ShowErrorAndExit ("Can not remove file / link.");
if (Str_FileIs (PathFileRel,"url"))
(Removed->NumLinks)++; // It's a link (URL inside a .url file)
@ -11447,14 +11447,17 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
if (Level > 1)
{
/* Count number of files in folder */
NumFiles = scandir (Path,&FileList,NULL,alphasort);
/* Free list of files */
for (NumFile = 0;
NumFile < NumFiles;
NumFile++)
free ((void *) FileList[NumFile]);
free ((void *) FileList);
if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error
{
/* Free list of files */
for (NumFile = 0;
NumFile < NumFiles;
NumFile++)
free ((void *) FileList[NumFile]);
free ((void *) FileList);
}
else
Lay_ShowErrorAndExit ("Error while scanning directory.");
}
}

View File

@ -91,7 +91,7 @@ cp -f /home/acanas/swad/swad/swad /var/www/cgi-bin/
/*****************************************************************************/
// In Eclipse, add to include path /usr/include, /usr/local/include, /usr/include/i386-linux-gnu
#include <dirent.h> // For dirent
#include <dirent.h> // For scandir, etc.
#include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <locale.h> // For setlocale, LC_NUMERIC...

View File

@ -470,9 +470,9 @@ static void ZIP_CompressFolderIntoZIP (void)
static unsigned long long ZIP_CloneDir (const char *Path,const char *PathClone,const char *PathInTree)
{
struct dirent **DirFileList;
int NumFileInThisDir;
int NumFilesInThisDir;
struct dirent **FileList;
int NumFile;
int NumFiles;
char PathFile[PATH_MAX+1];
char PathFileClone[PATH_MAX+1];
char PathFileInTree[PATH_MAX+1];
@ -489,60 +489,64 @@ static unsigned long long ZIP_CloneDir (const char *Path,const char *PathClone,c
unsigned long long FullSize = 0;
/***** Scan directory *****/
NumFilesInThisDir = scandir (Path,&DirFileList,NULL,alphasort);
if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error
{
/***** List files *****/
for (NumFile = 0;
NumFile < NumFiles;
NumFile++)
if (strcmp (FileList[NumFile]->d_name,".") &&
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
{
sprintf (PathFileInTree,"%s/%s",
PathInTree,FileList[NumFile]->d_name);
sprintf (PathFile,"%s/%s",
Path,FileList[NumFile]->d_name);
sprintf (PathFileClone,"%s/%s",
PathClone,FileList[NumFile]->d_name);
/***** List files *****/
for (NumFileInThisDir = 0;
NumFileInThisDir < NumFilesInThisDir;
NumFileInThisDir++)
if (strcmp (DirFileList[NumFileInThisDir]->d_name,".") &&
strcmp (DirFileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
{
sprintf (PathFileInTree,"%s/%s",PathInTree,DirFileList[NumFileInThisDir]->d_name);
sprintf (PathFile,"%s/%s",
Path,DirFileList[NumFileInThisDir]->d_name);
sprintf (PathFileClone,"%s/%s",
PathClone,DirFileList[NumFileInThisDir]->d_name);
lstat (PathFile,&FileStatus);
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
FileType = Brw_IS_FOLDER;
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
FileType = Str_FileIs (FileList[NumFile]->d_name,"url") ? Brw_IS_LINK : // It's a link (URL inside a .url file)
Brw_IS_FILE; // It's a file
else
FileType = Brw_IS_UNKNOWN;
lstat (PathFile,&FileStatus);
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
FileType = Brw_IS_FOLDER;
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
FileType = Str_FileIs (DirFileList[NumFileInThisDir]->d_name,"url") ? Brw_IS_LINK : // It's a link (URL inside a .url file)
Brw_IS_FILE; // It's a file
else
FileType = Brw_IS_UNKNOWN;
Hidden = (SeeDocsZone || SeeMarks) ? Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (FileType,PathFileInTree) :
false;
Hidden = (SeeDocsZone || SeeMarks) ? Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (FileType,PathFileInTree) :
false;
if (!Hidden) // If file/folder is not hidden
{
if (FileType == Brw_IS_FOLDER) // It's a directory
if (!Hidden) // If file/folder is not hidden
{
FullSize += (unsigned long long) FileStatus.st_size;
if (FileType == Brw_IS_FOLDER) // It's a directory
{
FullSize += (unsigned long long) FileStatus.st_size;
/***** Create clone of subdirectory *****/
if (mkdir (PathFileClone,(mode_t) 0xFFF))
Lay_ShowErrorAndExit ("Can not create temporary subfolder for compression.");
/***** Create clone of subdirectory *****/
if (mkdir (PathFileClone,(mode_t) 0xFFF))
Lay_ShowErrorAndExit ("Can not create temporary subfolder for compression.");
/***** Clone subtree starting at this this directory *****/
FullSize += ZIP_CloneDir (PathFile,PathFileClone,PathFileInTree);
/***** Clone subtree starting at this this directory *****/
FullSize += ZIP_CloneDir (PathFile,PathFileClone,PathFileInTree);
}
else if (FileType == Brw_IS_FILE ||
FileType == Brw_IS_LINK) // It's a regular file
{
FullSize += (unsigned long long) FileStatus.st_size;
/***** Create a symbolic link (clone) to original file *****/
if (symlink (PathFile,PathFileClone) != 0)
Lay_ShowErrorAndExit ("Can not create temporary link for compression.");
/***** Update number of my views of this file *****/
Brw_UpdateMyFileViews (Brw_GetFilCodByPath (PathFileInTree));
}
}
else if (FileType == Brw_IS_FILE ||
FileType == Brw_IS_LINK) // It's a regular file
{
FullSize += (unsigned long long) FileStatus.st_size;
/***** Create a symbolic link (clone) to original file *****/
if (symlink (PathFile,PathFileClone) != 0)
Lay_ShowErrorAndExit ("Can not create temporary link for compression.");
/***** Update number of my views of this file *****/
Brw_UpdateMyFileViews (Brw_GetFilCodByPath (PathFileInTree));
}
}
}
}
}
else
Lay_ShowErrorAndExit ("Error while scanning directory.");
return FullSize;
}