Skip to content

Commit

Permalink
fix(backend): don't run bump runs twice
Browse files Browse the repository at this point in the history
  • Loading branch information
dr460nf1r3 committed Dec 2, 2024
1 parent fcb157f commit f11336d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backend/src/repo-manager/repo-manager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ export class RepoManagerService {
class RepoManager {
changedArchPackages?: ArchlinuxPackage[];
status: RepoStatus = RepoStatus.INACTIVE;
statusDeploy: RepoStatus = RepoStatus.INACTIVE;

private readonly archlinuxRepos: string[] = ["core", "extra"];
private readonly archlinuxRepoUrl = (name: string) =>
Expand Down Expand Up @@ -534,6 +535,10 @@ class RepoManager {
Logger.log(`Checking repo ${repo.name} for rebuild triggers...`, "RepoManager");
Logger.debug(`Started cloning repo ${repo.name}`, "RepoManager");

if (this.status === RepoStatus.ACTIVE) {
Logger.warn("RepoManager is already active, skipping run", "RepoManager");
return { repo: repo.name, bumped: [], origin: TriggerType.ARCH };
}
this.status = RepoStatus.ACTIVE;
const repoDir: string = await this.createRepoDir(repo);

Expand Down Expand Up @@ -1456,6 +1461,12 @@ class RepoManager {
* @returns A map of the bumped package
*/
async checkPackageDepsAfterDeployment(build: Partial<Build>): Promise<BumpResult> {
if (this.statusDeploy === RepoStatus.ACTIVE) {
Logger.warn("Deployment is already in progress, skipping", "RepoManager");
return {repo: build.repo.name, bumped: [], origin: TriggerType.CHAOTIC};
}
this.statusDeploy = RepoStatus.ACTIVE

try {
const allPackages: Package[] = await this.dbConnections.packages.find({ where: { isActive: true } });
const needsRebuild: RepoUpdateRunParams[] = [];
Expand Down Expand Up @@ -1574,6 +1585,8 @@ class RepoManager {
await this.pushChanges(repoDir, needsPush, build.repo);
}

this.statusDeploy = RepoStatus.INACTIVE

return {
repo: build.repo.name,
bumped: bumped,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"axios": "^1.7.8",
"bcrypt": "^5.1.1",
"cache-manager": "^5.7.6",
"cron": "^3.2.1",
"crypto-js": "^4.2.0",
"fastify": "^4.28.1",
"flowbite": "^2.5.2",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f11336d

Please sign in to comment.