mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-06 15:03:26 +00:00
fixed duplicated repo url issue
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -143,3 +143,4 @@ manage-patchmon.sh
|
|||||||
setup-installer-site.sh
|
setup-installer-site.sh
|
||||||
install-server.*
|
install-server.*
|
||||||
notify-clients-upgrade.sh
|
notify-clients-upgrade.sh
|
||||||
|
debug-agent.sh
|
||||||
|
|||||||
@@ -332,7 +332,8 @@ router.post('/update', validateApiCredentials, [
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create host repository relationship
|
// Create host repository relationship (handle duplicates gracefully)
|
||||||
|
try {
|
||||||
await tx.hostRepository.create({
|
await tx.hostRepository.create({
|
||||||
data: {
|
data: {
|
||||||
hostId: host.id,
|
hostId: host.id,
|
||||||
@@ -341,6 +342,24 @@ router.post('/update', validateApiCredentials, [
|
|||||||
lastChecked: new Date()
|
lastChecked: new Date()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
// If it's a duplicate constraint error, update the existing record
|
||||||
|
if (error.code === 'P2002') {
|
||||||
|
await tx.hostRepository.updateMany({
|
||||||
|
where: {
|
||||||
|
hostId: host.id,
|
||||||
|
repositoryId: repo.id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
isEnabled: repoData.isEnabled !== false,
|
||||||
|
lastChecked: new Date()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Re-throw other errors
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user