21 char* commitHash =
fo_sysconfig(AGENT_NAME,
"COMMIT_HASH");
24 if (!commitHash || !version)
26 LOG_FATAL(
"Reuser: fo_sysconfig returned NULL for VERSION or COMMIT_HASH.");
30 char* revision =
nullptr;
31 if (asprintf(&revision,
"%s.%s", version, commitHash) < 0)
33 LOG_FATAL(
"Reuser: asprintf failed allocating revision string.");
38 AGENT_NAME, 0, revision, AGENT_DESC);
51 state.getAgentId(), AGENT_ARS,
nullptr, success);
54 void bail(
int exitval)
68 LOG_WARNING(
"Reuser: processBulkReuser failed for upload %d", uploadId);
74 for (
const auto& triple : reusedUploads)
80 LOG_WARNING(
"Reuser: could not determine parent bounds for reused"
81 " upload %d, skipping.", triple.reusedUploadId);
85 if (triple.reuseMode & REUSE_ENHANCED)
88 uploadId, triple.reusedUploadId,
89 groupId, triple.reusedGroupId, userId))
95 uploadId, triple.reusedUploadId,
96 groupId, triple.reusedGroupId, userId))
102 if (triple.reuseMode & REUSE_MAIN)
105 triple.reusedUploadId, triple.reusedGroupId))
106 LOG_WARNING(
"Reuser: reuseMainLicense failed for upload %d"
107 " (reused %d), continuing.",
108 uploadId, triple.reusedUploadId);
111 if (triple.reuseMode & REUSE_CONF)
114 LOG_WARNING(
"Reuser: reuseConfSettings failed for upload %d"
115 " (reused %d), continuing.",
116 uploadId, triple.reusedUploadId);
119 if (triple.reuseMode & REUSE_COPYRIGHT)
123 LOG_WARNING(
"Reuser: reuseCopyrights failed for upload %d"
124 " (reused %d), continuing.",
125 uploadId, triple.reusedUploadId);
bool processUploadId(const CompatibilityState &state, int uploadId, CompatibilityDatabaseHandler &databaseHandler, int groupId)
CompatibilityState getState(DbManager &dbManager, CompatibilityCliOptions &&cliOptions)
Create a new state for the current agent based on CliOptions.
int writeARS(const CompatibilityState &state, int arsId, int uploadId, int success, DbManager &dbManager)
int queryAgentId(DbManager &dbManager)
Query and register the agent id. Bails on failure.
void bail(int exitval)
Disconnect scheduler and exit.
Database handler for the reuser agent.
virtual bool processUploadReuse(int uploadId, int reusedUploadId, int groupId, int reusedGroupId, int userId)
virtual bool getParentItemBounds(int uploadId, ItemTreeBounds &out)
Fetch the parent item bounds for a given upload.
virtual bool reuseMainLicense(int uploadId, int groupId, int reusedUploadId, int reusedGroupId)
virtual bool processBulkReuser(int uploadId, int groupId, int userId)
virtual bool processEnhancedUploadReuse(int uploadId, int reusedUploadId, int groupId, int reusedGroupId, int userId)
virtual bool reuseCopyrights(int uploadId, int reusedUploadId, int userId)
virtual std::vector< ReuseTriple > getReusedUploads(int uploadId, int groupId)
Return the list of uploads that should be reused for uploadId.
virtual bool reuseConfSettings(int uploadId, int reusedUploadId)
Holds the runtime state of the reuser agent (agent id).
FUNCTION int fo_WriteARS(PGconn *pgConn, int ars_pk, int upload_pk, int agent_pk, const char *tableName, const char *ars_status, int ars_success)
Write ars record.
FUNCTION int fo_GetAgentKey(PGconn *pgConn, const char *agent_name, long Upload_pk, const char *rev, const char *agent_desc)
Get the latest enabled agent key (agent_pk) from the database.
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.
int fo_scheduler_userID()
Gets the id of the user that created the job that the agent is running.
int fo_scheduler_groupID()
Gets the id of the group that created the job that the agent is running.
fo_dbManager * dbManager
fo_dbManager object
fo namespace holds the FOSSology library functions.
Bounds of an item within an uploadtree table.