diff --git a/swad_changelog.h b/swad_changelog.h index 47cab6cd0..2bb78e7f6 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -118,12 +118,13 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.70 (2015/12/21)" +#define Log_PLATFORM_VERSION "SWAD 15.70.1 (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.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.69: Dec 20, 2015 New option in briefcase to ask for removing old files. (187270 lines) Version 15.68.1: Dec 20, 2015 Fixed bugs in connected users. (187171 lines) diff --git a/swad_file_browser.c b/swad_file_browser.c index ebcf93372..4380e5788 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -3425,7 +3425,8 @@ static void Brw_WriteTopBeforeShowingFileBrowser (void) break; case Brw_ADMI_BRIEF_USR: 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 (); break; default: @@ -11264,7 +11265,19 @@ void Brw_RemoveOldFiles (void) static void Brw_RemoveOldFilesInBrowser (void) { + extern const char *Txt_Folders_removed; + extern const char *Txt_Files_removed; + + /***** Remove old files recursively *****/ + Gbl.FileBrowser.Removed.NumFiles = + Gbl.FileBrowser.Removed.NumFolders = 0; Brw_ScanDirRemovingOlfFiles (1,Gbl.FileBrowser.Priv.PathRootFolder); + + /***** Success message *****/ + sprintf (Gbl.Message,"%s: %u. %s: %u.", + Txt_Folders_removed,Gbl.FileBrowser.Removed.NumFolders, + Txt_Files_removed ,Gbl.FileBrowser.Removed.NumFiles); + Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); } /*****************************************************************************/ @@ -11295,11 +11308,12 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path) if (strcmp (DirFileList[NumFileInThisDir]->d_name,".") && strcmp (DirFileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".." { + /***** Construct the full path of the file or folder *****/ sprintf (PathFileRel,"%s/%s",Path,DirFileList[NumFileInThisDir]->d_name); + /***** Get file or folder status *****/ lstat (PathFileRel,&FileStatus); - /***** Construct the full path of the file or folder *****/ if (S_ISDIR (FileStatus.st_mode)) // It's a directory { /***** Check if this subdirectory has files or folders in it *****/ @@ -11314,22 +11328,20 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path) NumFilesInThisSubdir = scandir (PathFileRel,&SubdirFileList,NULL,NULL); } - if (NumFilesInThisSubdir <= 2) // Empty directory + if (NumFilesInThisSubdir <= 2 && // It's an empty folder + FileStatus.st_mtime < TimeRemoveFilesOlder) // ..and it's old { - /* Remove folder if old */ - if (FileStatus.st_mtime < TimeRemoveFilesOlder) - Lay_ShowAlert (Lay_SUCCESS,PathFileRel); - else - Lay_ShowAlert (Lay_INFO,PathFileRel); + /* 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 { - /* Remove file if old */ - if (FileStatus.st_mtime < TimeRemoveFilesOlder) - Lay_ShowAlert (Lay_SUCCESS,PathFileRel); - else - Lay_ShowAlert (Lay_INFO,PathFileRel); + /* Remove file */ + Lay_ShowAlert (Lay_SUCCESS,PathFileRel); + Gbl.FileBrowser.Removed.NumFiles++; } } } diff --git a/swad_global.h b/swad_global.h index 0b87a35ca..d46b6d538 100644 --- a/swad_global.h +++ b/swad_global.h @@ -532,6 +532,11 @@ struct Globals bool CreateZIP; char TmpDir[NAME_MAX+1]; } ZIP; + struct + { + unsigned NumFiles; + unsigned NumFolders; + } Removed; // Number of old folders and files removed } FileBrowser; // Struct used for a file browser struct { diff --git a/swad_text.c b/swad_text.c index 5bba12935..de16732cc 100644 --- a/swad_text.c +++ b/swad_text.c @@ -11657,6 +11657,27 @@ const char *Txt_Files_of_marks_must_contain_a_table_in_HTML_format_ = " and footer rows."; // Necessita de tradução #endif +const char *Txt_Files_removed = +#if L==1 + "Arxius eliminats"; +#elif L==2 + "Dateien entfernt"; +#elif L==3 + "Files removed"; +#elif L==4 + "Archivos eliminados"; +#elif L==5 + "Fichiers supprimés"; +#elif L==6 + "Archivos eliminados"; // Okoteve traducción +#elif L==7 + "File rimossi"; +#elif L==8 + "Pliki usunięte"; +#elif L==9 + "Arquivos removidos"; +#endif + const char *Txt_Files_works = #if L==1 "Archivos trabajos"; // Necessita traduccio @@ -11930,6 +11951,27 @@ const char *Txt_Folders_renamed = "Diretórios renomeados"; #endif +const char *Txt_Folders_removed = +#if L==1 + "Carpetes eliminades"; +#elif L==2 + "Verzeichnisse entfernt"; +#elif L==3 + "Folders removed"; +#elif L==4 + "Carpetas eliminadas"; +#elif L==5 + "Répertoires supprimés"; +#elif L==6 + "Carpetas eliminadas"; // Okoteve traducción +#elif L==7 + "Cartelle rimossi"; +#elif L==8 + "Foldery usunięte"; +#elif L==9 + "Diretórios removidos"; +#endif + const char *Txt_Folders_not_renamed = #if L==1 "Carpetes no anomenades";