FOSSology  4.4.0
Open Source License Compliance by Open Source Software
process.c
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2013 Hewlett-Packard Development Company, L.P.
3  SPDX-FileCopyrightText: © 2014-2015, 2019 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
12 #include "maintagent.h"
13 
14 /********** Globals *************/
15 PGconn* pgConn = NULL;
17 
26 PGresult * PQexecCheck(int exitNumber, char *SQL, char *file, const int line)
27 {
28  PGresult *result;
29  result = PQexec(pgConn, SQL);
30  if (fo_checkPQcommand(pgConn, result, SQL, file, line)) {
31  PQclear(result);
32  exitNow(exitNumber);
33  }
34  return result;
35 }
36 
42 FUNCTION void PQexecCheckClear(int exitNumber, char *SQL, char *file, const int line)
43 {
44  PGresult *result;
45  result = PQexecCheck(exitNumber, SQL, file, line);
46  PQclear(result);
47 }
48 
53 FUNCTION void vacAnalyze()
54 {
55  long startTime, endTime;
56  char *SQL = "VACUUM ANALYZE";
57 
58  startTime = (long)time(0);
59 
60  /* Vacuum and Analyze */
61  PQexecCheckClear(-110, SQL, __FILE__, __LINE__);
62 
63  endTime = (long)time(0);
64  printf("Vacuum Analyze took %ld seconds\n", endTime-startTime);
65 
66  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
67  return; // success
68 }
69 
75 FUNCTION void validateFolders()
76 {
77  PGresult* result; // the result of the database access
78  char *countTuples;
79 
80  char *invalidUploadRefs = "DELETE FROM foldercontents WHERE foldercontents_mode = 2 AND child_id NOT IN (SELECT upload_pk FROM upload)";
81  char *invalidUploadtreeRefs = "DELETE FROM foldercontents WHERE foldercontents_mode = 4 AND child_id NOT IN (SELECT uploadtree_pk FROM uploadtree)";
82  char *unRefFolders = "DELETE FROM folder WHERE folder_pk \
83  NOT IN (SELECT child_id FROM foldercontents WHERE foldercontents_mode = 1) AND folder_pk != '1'";
84  long startTime, endTime;
85 
86  startTime = (long)time(0);
87 
88  /* Remove folder contents with invalid upload references */
89  result = PQexecCheck(-120, invalidUploadRefs, __FILE__, __LINE__);
90  countTuples = PQcmdTuples(result);
91  PQclear(result);
92  printf("%s Invalid folder upload References\n", countTuples);
93 
94  /* Remove folder contents with invalid uploadtree references */
95  result = PQexecCheck(-121, invalidUploadtreeRefs, __FILE__, __LINE__);
96  countTuples = PQcmdTuples(result);
97  PQclear(result);
98  printf("%s Invalid folder uploadtree References\n", countTuples);
99 
100  /* Remove unreferenced folders */
101  result = PQexecCheck(-122, unRefFolders, __FILE__, __LINE__);
102  countTuples = PQcmdTuples(result);
103  PQclear(result);
104  printf("%s unreferenced folders\n", countTuples);
105 
106  endTime = (long)time(0);
107  printf("Validate folders took %ld seconds\n", endTime-startTime);
108 
109  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
110  return; // success
111 }
112 
128 FUNCTION void verifyFilePerms(int fix)
129 {
130 /*
131  long StartTime, EndTime;
132  char *RepoPath;
133 
134  StartTime = (long)time(0);
135 
136  RepoPath = fo_sysconfig("FOSSOLOGY", "path");
137  if (stat(RepoPath, &statbuf) == -1)
138  {
139  }
140 
141  EndTime = (long)time(0);
142  printf("Verify File Permissions took %ld seconds\n", EndTime-StartTime);
143 */
144  LOG_NOTICE("Verify file permissions is not implemented yet");
145 
146  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
147  return; // success
148 }
149 
155 FUNCTION void removeUploads()
156 {
157  PGresult* result; // the result of the database access
158  char *countTuples;
159  long startTime, endTime;
160 
161  char *SQL = "DELETE FROM upload WHERE upload_pk \
162  IN (SELECT upload_fk FROM uploadtree WHERE parent IS NULL AND pfile_fk IS NULL) \
163  OR (upload_pk NOT IN (SELECT upload_fk FROM uploadtree) \
164  AND (expire_action IS NULL OR expire_action != 'd') AND pfile_fk IS NOT NULL)";
165 
166  startTime = (long)time(0);
167 
168  result = PQexecCheck(-130, SQL, __FILE__, __LINE__);
169  countTuples = PQcmdTuples(result);
170  PQclear(result);
171 
172  endTime = (long)time(0);
173  printf("%s Uploads with no pfiles (%ld seconds)\n", countTuples, endTime-startTime);
174 
175  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
176  return; // success
177 }
178 
183 FUNCTION void removeTemps()
184 {
185  PGresult* result;
186  int row;
187  int countTuples;
188  int droppedCount = 0;
189  char SQLBuf[MAXSQL];
190  long startTime, endTime;
191 
192  char *SQL = "SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE'"
193  "AND table_schema = 'public' AND (table_name SIMILAR TO '^metaanalysis_[[:digit:]]+$'"
194  "OR table_name SIMILAR TO '^delup_%');";
195 
196  startTime = (long)time(0);
197 
198  result = PQexec(pgConn, SQL);
199  if (fo_checkPQresult(pgConn, result, SQL, __FILE__, __LINE__)) exitNow(-140);
200  countTuples = PQntuples(result);
201  /* Loop through the temp table names, dropping the tables */
202  for (row = 0; row < countTuples; row++) {
203  snprintf(SQLBuf, MAXSQL, "DROP TABLE %s", PQgetvalue(result, row, 0));
204  PQexecCheckClear(-141, SQLBuf, __FILE__, __LINE__);
205  droppedCount++;
206  }
207  PQclear(result);
208 
209  endTime = (long)time(0);
210  printf("%d Orphaned temp tables were dropped (%ld seconds)\n", droppedCount, endTime-startTime);
211 
212  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
213  return; // success
214 }
215 
221 FUNCTION void processExpired()
222 {
223 /*
224  PGresult* result; // the result of the database access
225  int numrows; // generic return value
226  long StartTime, EndTime;
227 
228  StartTime = (long)time(0);
229 
230  EndTime = (long)time(0);
231  printf("Process expired uploads took %ld seconds\n", EndTime-StartTime);
232 */
233  LOG_NOTICE("Process expired uploads is not implemented yet");
234 
235  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
236  return; // success
237 }
238 
246 FUNCTION void removeOrphanedFiles()
247 {
248  long StartTime, EndTime;
249  char* repoPath;
250  char filesPath[myBUFSIZ];
251 
252  StartTime = (long)time(0);
253 
254  repoPath = fo_sysconfig("FOSSOLOGY", "path");
255  strncpy(filesPath, repoPath, myBUFSIZ - 1);
256  strncat(filesPath, "/localhost/files", myBUFSIZ - 1);
257 
258  if (access(filesPath, R_OK | W_OK) != 0)
259  {
260  LOG_ERROR("Files path is not readable/writeable: '%s'", filesPath);
261  }
262  else
263  {
264  recurseDir("files", filesPath, 3);
265  }
266 
267  EndTime = (long)time(0);
268  printf("Remove orphaned files from the repository took %ld seconds\n",
269  EndTime - StartTime);
270 
271  return; // success
272 }
273 
281 FUNCTION void deleteOrphanGold()
282 {
283  long StartTime, EndTime;
284  char* repoPath;
285  char goldPath[myBUFSIZ];
286 
287  StartTime = (long)time(0);
288 
289  repoPath = fo_sysconfig("FOSSOLOGY", "path");
290  strncpy(goldPath, repoPath, myBUFSIZ - 1);
291  strncat(goldPath, "/localhost/gold", myBUFSIZ - 1);
292 
293  if (access(goldPath, R_OK | W_OK) != 0)
294  {
295  LOG_ERROR("Gold path is not readable/writeable: '%s'", goldPath);
296  }
297  else
298  {
299  recurseDir("gold", goldPath, 3);
300  }
301 
302  EndTime = (long)time(0);
303  printf("Remove orphaned gold files from the repository took %ld seconds\n",
304  EndTime - StartTime);
305 
306  return; // success
307 }
308 
314 {
315  long startTime, endTime;
316 
317  char *SQL1 = "CREATE TEMPORARY TABLE tmp_upload_prio(ordprio serial, uploadid int, groupid int)";
318  char *SQL2 = "INSERT INTO tmp_upload_prio (uploadid, groupid) (SELECT upload_fk uploadid, group_fk groupid FROM upload_clearing ORDER BY priority ASC);";
319  char *SQL3 = "UPDATE upload_clearing SET priority = ordprio FROM tmp_upload_prio WHERE uploadid=upload_fk AND group_fk=groupid;";
320 
321  startTime = (long)time(0);
322 
323  PQexecCheckClear(-180, SQL1, __FILE__, __LINE__);
324  PQexecCheckClear(-181, SQL2, __FILE__, __LINE__);
325  PQexecCheckClear(-182, SQL3, __FILE__, __LINE__);
326 
327  endTime = (long)time(0);
328  printf("Normalized upload priorities (%ld seconds)\n", endTime-startTime);
329 
330  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
331  return; // success
332 }
333 
338 FUNCTION void reIndexAllTables()
339 {
340  PGresult* result; // the result of the database access
341  char SQLBuf[MAXSQL];
342  long startTime, endTime;
343  char *SQL= "SELECT table_catalog FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema = 'public' AND (table_name SIMILAR TO 'upload%') LIMIT 1";
344 
345  startTime = (long)time(0);
346 
347  result = PQexec(pgConn, SQL);
348  if (fo_checkPQresult(pgConn, result, SQL, __FILE__, __LINE__)) exitNow(-190);
349 
350  memset(SQLBuf,'\0',sizeof(SQLBuf));
351  snprintf(SQLBuf,sizeof(SQLBuf),"REINDEX DATABASE %s;", PQgetvalue(result, 0, 0));
352  PQclear(result);
353  PQexecCheckClear(-191, SQLBuf, __FILE__, __LINE__);
354 
355  endTime = (long)time(0);
356  printf("Time taken for reindexing the database : %ld seconds\n", endTime-startTime);
357 
358  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
359  return; // success
360 }
361 
366 FUNCTION void removeOrphanedRows()
367 {
368  PGresult* result; // the result of the database access
369  char *countTuples;
370  long startTime, endTime;
371 
372  char *SQL1 = "DELETE FROM uploadtree UT "
373  " WHERE NOT EXISTS ( "
374  " SELECT 1 "
375  " FROM upload U "
376  " WHERE UT.upload_fk = U.upload_pk "
377  " );";
378 
379  char *SQL2 = "DELETE FROM clearing_decision AS CD "
380  " WHERE NOT EXISTS ( "
381  " SELECT 1 "
382  " FROM uploadtree UT "
383  " WHERE CD.uploadtree_fk = UT.uploadtree_pk "
384  " ) AND CD.scope = '0';";
385 
386  char *SQL3 = "DELETE FROM clearing_event CE "
387  " WHERE NOT EXISTS ( "
388  " SELECT 1 "
389  " FROM uploadtree UT "
390  " WHERE CE.uploadtree_fk = UT.uploadtree_pk "
391  " ) AND NOT EXISTS ( "
392  " SELECT 1 "
393  " FROM clearing_decision CD"
394  " WHERE CD.uploadtree_fk = CE.uploadtree_fk "
395  " AND CD.scope = '1'"
396  " );";
397 
398  char *SQL4 = "DELETE FROM clearing_decision_event CDE"
399  " WHERE NOT EXISTS ( "
400  " SELECT 1 "
401  " FROM clearing_event CE "
402  " WHERE CE.clearing_event_pk = CDE.clearing_event_fk "
403  " );";
404 
405  char *SQL5 = "DELETE FROM obligation_map OM "
406  " WHERE NOT EXISTS ( "
407  " SELECT 1 "
408  " FROM license_ref LR "
409  " WHERE OM.rf_fk = LR.rf_pk "
410  " );";
411 
412  char *SQL6 = "DELETE FROM obligation_candidate_map OCM "
413  " WHERE NOT EXISTS ( "
414  " SELECT 1 "
415  " FROM license_ref LR "
416  " WHERE OCM.rf_fk = LR.rf_pk "
417  " );";
418 
419  startTime = (long)time(0);
420 
421  result = PQexecCheck(-200, SQL1, __FILE__, __LINE__);
422  countTuples = PQcmdTuples(result);
423  PQclear(result);
424  printf("%s Orphaned records have been removed from uploadtree table\n", countTuples);
426 
427  result = PQexecCheck(-201, SQL2, __FILE__, __LINE__);
428  countTuples = PQcmdTuples(result);
429  PQclear(result);
430  printf("%s Orphaned records have been removed from clearing_decision table\n", countTuples);
432 
433  result = PQexecCheck(-202, SQL3, __FILE__, __LINE__);
434  countTuples = PQcmdTuples(result);
435  PQclear(result);
436  printf("%s Orphaned records have been removed from clearing_event table\n", countTuples);
438 
439  result = PQexecCheck(-203, SQL4, __FILE__, __LINE__);
440  countTuples = PQcmdTuples(result);
441  PQclear(result);
442  printf("%s Orphaned records have been removed from clearing_decision_event table\n", countTuples);
444 
445  result = PQexecCheck(-204, SQL5, __FILE__, __LINE__);
446  countTuples = PQcmdTuples(result);
447  PQclear(result);
448  printf("%s Orphaned records have been removed from obligation_map table\n", countTuples);
450 
451  result = PQexecCheck(-205, SQL6, __FILE__, __LINE__);
452  countTuples = PQcmdTuples(result);
453  PQclear(result);
454  printf("%s Orphaned records have been removed from obligation_candidate_map table\n", countTuples);
455  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
456 
457  endTime = (long)time(0);
458 
459  printf("Time taken for removing orphaned rows from database : %ld seconds\n", endTime-startTime);
460 
461  return; // success
462 }
463 
464 
469 FUNCTION void removeOrphanedLogFiles()
470 {
471  PGresult* result;
472  PGresult* updateResult;
473  int row;
474  int countTuples;
475  int removedCount = 0;
476  int jobQueueId;
477  char* logPath;
478  long startTime, endTime;
479  fo_dbManager_PreparedStatement* updateStatement;
480  struct stat statbuf;
481 
482  char *SQL = "SELECT jq_pk, jq_log FROM job ja "
483  "INNER JOIN job jb ON ja.job_upload_fk = jb.job_upload_fk "
484  "INNER JOIN jobqueue jq ON jb.job_pk = jq.jq_job_fk "
485  "WHERE ja.job_name = 'Delete' AND jq_log IS NOT NULL "
486  "AND jq_log != 'removed';";
487 
488  startTime = (long)time(0);
489 
490  result = PQexec(pgConn, SQL);
491  if (fo_checkPQresult(pgConn, result, SQL, __FILE__, __LINE__))
492  {
493  exitNow(-140);
494  }
495  countTuples = PQntuples(result);
496 
497  updateStatement = fo_dbManager_PrepareStamement(dbManager,
498  "updateRemovedLogFromJobqueue",
499  "UPDATE jobqueue SET jq_log = 'removed' WHERE jq_pk = $1;", int);
500  /* Loop through the logs found and delete them. Also update the database */
501  for (row = 0; row < countTuples; row++)
502  {
503  fo_dbManager_begin(dbManager);
504  jobQueueId = atoi(PQgetvalue(result, row, 0));
505  logPath = PQgetvalue(result, row, 1);
506  if (stat(logPath, &statbuf) == -1)
507  {
508  LOG_NOTICE("Log file '%s' does not exists", logPath);
509  }
510  else
511  {
512  remove(logPath);
513  LOG_VERBOSE2("Removed file '%s'", logPath);
514  }
515  updateResult = fo_dbManager_ExecPrepared(updateStatement, jobQueueId);
516  if (updateResult)
517  {
518  free(updateResult);
519  removedCount++;
520  }
521  else
522  {
523  LOG_ERROR("Unable to update the value of jobqueue.jq_log to 'removed' "
524  "for jq_pk = %d", jobQueueId);
525  }
526  fo_dbManager_commit(dbManager);
527  }
528  PQclear(result);
529 
530  endTime = (long)time(0);
531  printf("%d / %d Orphaned log files were removed "
532  "(%ld seconds)\n", removedCount, countTuples, endTime - startTime);
533 
534  fo_scheduler_heart(1); // Tell the scheduler that we are alive and update item count
535  return; // success
536 }
537 
542 FUNCTION void removeExpiredTokens(long int retentionPeriod)
543 {
544  PGresult* result; // the result of the database access
545  char *countTuples;
546  long startTime, endTime;
547  char SQL[1024];
548  time_t current_time = time(0);
549  time_t shifted_time = current_time - (retentionPeriod*24*60*60);
550  struct tm time_structure = *localtime(&shifted_time);
551 
552  snprintf(SQL, sizeof(SQL),
553  "DELETE FROM personal_access_tokens WHERE (active = 'FALSE' OR expire_on < '%d-%02d-%02d') AND client_id IS NULL",
554  time_structure.tm_year + 1900,
555  time_structure.tm_mon + 1,
556  time_structure.tm_mday
557  );
558 
559  startTime = (long)time(0);
560 
561  result = PQexecCheck(-220, SQL, __FILE__, __LINE__);
562  countTuples = PQcmdTuples(result);
563  PQclear(result);
564  printf("%s Expired personal access tokens have been removed from personal_access_tokens table\n", countTuples);
566 
567  endTime = (long)time(0);
568 
569  printf("Time taken for removing expired personal access tokens from database : %ld seconds\n", endTime-startTime);
570 
571  return; // success
572 }
573 
581 FUNCTION void deleteOldGold(char* date)
582 {
583  PGresult* result; // the result of the database access
584  int numrows = 0; // generic return value
585  long StartTime, EndTime;
586  int countTuples, row, remval;
587  int day, month, year; // Date validation
588  char* filepath;
589  char sql[MAXSQL];
590 
591  day = month = year = -1;
592  sscanf(date, "%4d-%2d-%2d", &year, &month, &day);
593  if (((year < 1900) || (year > 9999)) || ((month < 1) || (month > 12)) ||
594  ((day < 1) || (day > 31)))
595  {
596  LOG_FATAL("Invalid date! Require yyyy-mm-dd, '%s' given.", date);
597  exitNow(-144);
598  }
599 
600  snprintf(sql, MAXSQL,
601  "SELECT DISTINCT ON(pfile_pk) "
602  "CONCAT(LOWER(pfile_sha1), '.', LOWER(pfile_md5), '.', pfile_size) "
603  "AS filename FROM upload INNER JOIN pfile ON pfile_pk = pfile_fk "
604  "WHERE upload_ts < '%s' AND pfile_fk NOT IN ("
605  "SELECT pfile_fk FROM upload WHERE upload_ts > '%s' "
606  "AND pfile_fk IS NOT NULL);",
607  date, date);
608 
609  StartTime = (long)time(0);
610 
611  result = PQexec(pgConn, sql);
612  if (fo_checkPQresult(pgConn, result, sql, __FILE__, __LINE__))
613  {
614  exitNow(-145);
615  }
616  countTuples = PQntuples(result);
617  if (agent_verbose)
618  {
619  LOG_DEBUG("Read %d rows from DB.", countTuples);
620  }
621  /* Loop through the pfiles and remove them from repository */
622  for (row = 0; row < countTuples; row++)
623  {
624  filepath = fo_RepMkPath("gold", PQgetvalue(result, row, 0));
625  remval = remove(filepath);
626  if (remval < 0)
627  {
628  if (errno != ENOENT)
629  {
630  // Removal failed and error != file not exist
631  LOG_WARNING("Unable to remove '%s' file.", filepath);
632  }
633  }
634  else
635  {
636  numrows++;
637  }
638  free(filepath);
639  }
640  PQclear(result);
641 
642  EndTime = (long)time(0);
643  printf("Removed %d old gold files from the repository, took %ld seconds\n",
644  numrows, EndTime - StartTime);
645 
647  1); // Tell the scheduler that we are alive and update item count
648  return; // success
649 }
650 
651 /*
652  * @brief Delete all log files older than given date in olderThan param
653  *
654  * -# Use find to list all files in a temporary location.
655  * -# Use the number of lines in the file to get the total no of files.
656  * -# Feed the file to xargs and call rm to remove them.
657  * -# Close the fd and unlink the temporary file.
658  * @param olderThan Delete logs older than this date (YYYY-MM-DD)
659  */
660 FUNCTION void removeOldLogFiles(const char* olderThan)
661 {
662  time_t current_time = time(0);
663  time_t shifted_time;
664  time_t ellapsed_time;
665  struct tm ti = {0};
666  char cmd[myBUFSIZ];
667  unsigned int numfiles = 0;
668  long StartTime, EndTime;
669  char ch;
670  FILE* tempFile;
671  int retval;
672 
673  StartTime = (long)time(0);
674  if (sscanf(olderThan, "%d-%d-%d", &ti.tm_year, &ti.tm_mon, &ti.tm_mday) != 3)
675  {
676  LOG_FATAL("Unable to parse date '%s' in YYYY-MM-DD format.", olderThan);
677  exitNow(-148);
678  }
679  ti.tm_year -= 1900;
680  ti.tm_mon -= 1;
681  shifted_time = mktime(&ti);
682  ellapsed_time = (current_time - shifted_time) / 60 / 60 / 24 - 1;
683 
684  char file_template[] = "/tmp/foss-XXXXXX";
685  int fd = mkstemp(file_template);
686 
687  snprintf(cmd, myBUFSIZ, "/usr/bin/find %s/logs -type f -mtime +%ld -fprint %s",
688  fo_sysconfig("FOSSOLOGY", "path"), ellapsed_time, file_template);
689  retval = system(cmd); // Find and print files in temp location
690  if (!WIFEXITED(retval))
691  { // find fail
692  LOG_FATAL("Unable run find for logs files.");
693  unlink(file_template);
694  exitNow(-148);
695  }
696  tempFile = fdopen(fd, "r");
697  if (tempFile == NULL)
698  {
699  LOG_FATAL("Unable to open temp file.");
700  unlink(file_template);
701  exitNow(-148);
702  }
703  while ((ch = fgetc(tempFile)) != EOF)
704  {
705  if (ch == '\n')
706  {
707  numfiles++;
708  }
709  }
710 
711  snprintf(cmd, myBUFSIZ, "/usr/bin/xargs --arg-file=%s /bin/rm -f", file_template);
712  retval = system(cmd);
713  if (!WIFEXITED(retval))
714  { // xargs fail
715  LOG_FATAL("Unable delete log files with xargs.");
716  fclose(tempFile);
717  unlink(file_template);
718  exitNow(-148);
719  }
720  fclose(tempFile);
721  unlink(file_template);
722 
723  EndTime = (long)time(0);
724 
725  printf("Removed %d log files.\n", numfiles);
726 
727  printf(
728  "Removing log files older than '%s' from the repository took %ld "
729  "seconds\n",
730  olderThan, EndTime - StartTime);
731 
733  return;
734 }
char SQL[256]
SQL query to execute.
Definition: adj2nest.c:78
void exitNow(int exitVal)
Exit function. This does all cleanup and should be used instead of calling exit() or main() return.
Definition: util.c:1131
PGconn * pgConn
Database connection.
Definition: adj2nest.c:86
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
Definition: libfossdb.c:170
int fo_checkPQcommand(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres commands (not select) If an error occured, write the error to s...
Definition: libfossdb.c:204
char * fo_RepMkPath(const char *Type, char *Filename)
Given a filename, construct the full path to the file.
Definition: libfossrepo.c:352
void fo_scheduler_heart(int i)
This function must be called by agents to let the scheduler know they are alive and how many items th...
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.
int agent_verbose
Common verbose flags for the agents, this is used so that the scheduler can change the verbose level ...
FUNCTION void removeOrphanedRows()
remove orphaned rows from fossology database
Definition: process.c:366
FUNCTION void verifyFilePerms(int fix)
Verify and optionally fix file permissions.
Definition: process.c:128
FUNCTION void deleteOldGold(char *date)
Delete gold files which are older than specified date.
Definition: process.c:581
FUNCTION void removeTemps()
Remove orphaned temp tables from deprecated pkgmettagetta and old delagent.
Definition: process.c:183
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:16
PGresult * PQexecCheck(int exitNumber, char *SQL, char *file, const int line)
simple wrapper which includes PQexec and fo_checkPQcommand
Definition: process.c:26
FUNCTION void reIndexAllTables()
reindex of all indexes in fossology database
Definition: process.c:338
FUNCTION void removeOldLogFiles(const char *olderThan)
Definition: process.c:660
FUNCTION void removeUploads()
Remove Uploads with no pfiles.
Definition: process.c:155
FUNCTION void removeOrphanedLogFiles()
Definition: process.c:469
FUNCTION void PQexecCheckClear(int exitNumber, char *SQL, char *file, const int line)
Execute SQL query and create the result and clear the result.
Definition: process.c:42
FUNCTION void processExpired()
Process expired uploads (slow)
Definition: process.c:221
FUNCTION void removeExpiredTokens(long int retentionPeriod)
remove expired personal access tokens from fossology database
Definition: process.c:542
FUNCTION void validateFolders()
Validate folder and foldercontents tables.
Definition: process.c:75
FUNCTION void removeOrphanedFiles()
Remove orphaned files from the repository (slow) Loop through each file in the repository and make su...
Definition: process.c:246
FUNCTION void vacAnalyze()
Do database vacuum and analyze.
Definition: process.c:53
FUNCTION void deleteOrphanGold()
Delete orphaned gold files from the repository.
Definition: process.c:281
FUNCTION void normalizeUploadPriorities()
Normalize priority of Uploads.
Definition: process.c:313
FUNCTION void recurseDir(const char *type, char *path, int level)
Recursively read directory till level is 0.
Definition: utils.c:67
PGresult * fo_dbManager_ExecPrepared(fo_dbManager_PreparedStatement *preparedStatement,...)
Execute a prepared statement.
Definition: standalone.c:36