From 27b118cafcb99a553561b02894a627ecd381593e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 21 Feb 2019 17:34:53 +0100 Subject: [PATCH] Version 18.52.3 --- swad_changelog.h | 5 ++-- swad_file.c | 70 ++++++++++++++++++++++----------------------- swad_file_browser.c | 14 ++++----- swad_zip.c | 6 ++-- 4 files changed, 47 insertions(+), 48 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 868fa45af..a2b6879d1 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -399,8 +399,6 @@ Antonio // TODO: Chequear todos los iconos .gif y .png que restan, concretamente los de file_browser -// TODO: Sale de vez en cuando un mensaje "Can not get information about a file or folder.", por ejemplo en el timeline. - // TODO: Pedro Villar Castro: // Al asignar un TFG a alumnos, no escribir el DNI del alumno, sino escogerlo de una lista de entre los alumnos inscritos en la asignatura. @@ -431,10 +429,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.52.2 (2019-02-21)" +#define Log_PLATFORM_VERSION "SWAD 18.52.3 (2019-02-21)" #define CSS_FILE "swad18.52.css" #define JS_FILE "swad18.51.js" /* + Version 18.52.3: Feb 21, 2019 Fixed bug in removing of old temporary files. (237458 lines) Version 18.52.2: Feb 20, 2019 Fixed bug in reception of images. (237458 lines) Version 18.52.1: Feb 20, 2019 Messages to debug problem with files. (237425 lines) Version 18.52: Feb 20, 2019 Two new color themes: purple and pink. (237424 lines) diff --git a/swad_file.c b/swad_file.c index 29962b38f..ced747610 100644 --- a/swad_file.c +++ b/swad_file.c @@ -431,7 +431,7 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1]) if (Fil_CheckIfPathExists (Path)) { if (lstat (Path,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in Fil_RemoveTree."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else if (S_ISDIR (FileStatus.st_mode)) // It's a directory { if (rmdir (Path)) @@ -496,44 +496,44 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDire char Path2[PATH_MAX + 1]; struct stat FileStatus; - if (lstat (Path,&FileStatus)) // On success ==> 0 is returned - { - Ale_ShowAlert (Ale_ERROR,"Error while trying to remove old temporary files in directory "%s"",Path); - Lay_ShowErrorAndExit ("Can not get information about a file or folder in Fil_RemoveOldTmpFiles."); - } - else if (S_ISDIR (FileStatus.st_mode)) // It's a directory - { - /***** Scan the directory *****/ - if ((NumFiles = scandir (Path,&FileList,NULL,NULL)) >= 0) // No error - { - /* Loop over files */ - for (NumFile = 0; - NumFile < NumFiles; - NumFile++) + /***** 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 { - if (strcmp (FileList[NumFile]->d_name,".") && - strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".." + /***** Scan the directory and delete recursively *****/ + if ((NumFiles = scandir (Path,&FileList,NULL,NULL)) >= 0) // No error { - snprintf (Path2,sizeof (Path2), - "%s/%s", - Path,FileList[NumFile]->d_name); - Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call - } - free ((void *) FileList[NumFile]); - } - free ((void *) FileList); + /* Loop over files */ + for (NumFile = 0; + NumFile < NumFiles; + NumFile++) + { + 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]); + } + free ((void *) FileList); - if (RemoveDirectory) - /* Remove the directory itself */ + if (RemoveDirectory) + /* Remove the directory itself */ + if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove) + rmdir (Path); + } + else + Lay_ShowErrorAndExit ("Error while scanning directory."); + } + else // Not a directory if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove) - rmdir (Path); - } - else - Lay_ShowErrorAndExit ("Error while scanning directory."); - } - else - if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove) - unlink (Path); + unlink (Path); + } } /*****************************************************************************/ diff --git a/swad_file_browser.c b/swad_file_browser.c index b3cff439b..fb7edcac5 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -5352,7 +5352,7 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path) "%s/%s", Path,FileList[NumFile]->d_name); if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_CalcSizeOfDirRecursive."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else if (S_ISDIR (FileStatus.st_mode)) // It's a directory { Gbl.FileBrowser.Size.NumFolds++; @@ -5423,7 +5423,7 @@ static void Brw_ListDir (unsigned Level,const char *ParentRowId, /***** Get file or folder status *****/ if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_ListDir."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else if (S_ISDIR (FileStatus.st_mode)) // It's a directory { if (Gbl.FileBrowser.FullTree) @@ -6764,7 +6764,7 @@ void Brw_RemFileFromTree (void) /***** Check if is a file/link or a folder *****/ if (lstat (Path,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_RemFileFromTree."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else if (S_ISREG (FileStatus.st_mode)) // It's a file or a link { /* Name of the file/link to be shown */ @@ -6818,7 +6818,7 @@ void Brw_RemFolderFromTree (void) /***** Check if it's a file or a folder *****/ if (lstat (Path,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_RemFolderFromTree."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else if (S_ISDIR (FileStatus.st_mode)) // It's a directory if (Brw_RemoveFolderFromDiskAndDB (Path, Gbl.FileBrowser.Priv.FullPathInTree)) @@ -8288,7 +8288,7 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg, /***** Is it a file or a folder? *****/ FileType = Brw_IS_UNKNOWN; if (lstat (PathOrg,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_PasteTreeIntoFolder."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else 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 @@ -12558,7 +12558,7 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level, // Folder st_mtime must be saved before remove files inside it // because st_mtime is updated by the deletion if (lstat (Path,&FolderStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_ScanDirRemovingOldFiles."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); /***** Scan directory *****/ else if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error { @@ -12580,7 +12580,7 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level, /***** Get file or folder status *****/ if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_ScanDirRemovingOldFiles."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else if (S_ISDIR (FileStatus.st_mode)) // It's a folder /* Scan subtree starting at this this directory recursively */ Brw_ScanDirRemovingOldFiles (Level + 1,PathFileRel, diff --git a/swad_zip.c b/swad_zip.c index c6915859c..31cb01af1 100644 --- a/swad_zip.c +++ b/swad_zip.c @@ -236,7 +236,7 @@ void ZIP_CreateZIPAsgWrk (void) { /***** Get file size *****/ if (lstat (PathFileZIP,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in ZIP_CreateZIPAsgWrk."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else { /***** Create URL pointing to ZIP file *****/ @@ -489,7 +489,7 @@ static void ZIP_CompressFolderIntoZIP (void) { /***** Get file size *****/ if (lstat (PathFileZIP,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in ZIP_CompressFolderIntoZIP."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else { /***** Create URL pointing to ZIP file *****/ @@ -574,7 +574,7 @@ static unsigned long long ZIP_CloneDir (const char *Path,const char *PathClone,c FileType = Brw_IS_UNKNOWN; if (lstat (PathFile,&FileStatus)) // On success ==> 0 is returned - Lay_ShowErrorAndExit ("Can not get information about a file or folder in ZIP_CloneDir."); + Lay_ShowErrorAndExit ("Can not get information about a file or folder."); else 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