Skip to content

Commit a11479a

Browse files
committed
Remove existing assets if the size does not match.
1 parent 06cf2d3 commit a11479a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

internal/push/push.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,16 @@ func (pushService *pushService) uploadReleaseAsset(release *github.RepositoryRel
300300
func (pushService *pushService) createOrUpdateReleaseAsset(release *github.RepositoryRelease, existingAssets []*github.ReleaseAsset, assetPathStat os.FileInfo) error {
301301
for _, existingAsset := range existingAssets {
302302
if existingAsset.GetName() == assetPathStat.Name() {
303-
if int64(existingAsset.GetSize()) == assetPathStat.Size() {
303+
actualSize := int64(existingAsset.GetSize())
304+
expectedSize := assetPathStat.Size()
305+
if actualSize == expectedSize {
304306
return nil
307+
} else {
308+
log.Warnf("Removing existing release asset %s because it was only partially-uploaded (had size %d, but should have been %d)...", existingAsset.GetName(), actualSize, expectedSize)
309+
_, err := pushService.githubEnterpriseClient.Repositories.DeleteReleaseAsset(pushService.ctx, pushService.destinationRepositoryOwner, pushService.destinationRepositoryName, existingAsset.GetID())
310+
if err != nil {
311+
return errors.Wrap(err, "Error deleting existing release asset.")
312+
}
305313
}
306314
}
307315
}
@@ -333,6 +341,7 @@ func (pushService *pushService) pushReleases() error {
333341
}
334342
for _, releasePathStat := range releasePathStats {
335343
releaseName := releasePathStat.Name()
344+
log.Debugf("Pushing CodeQL bundles release %s...", releaseName)
336345
release, err := pushService.createOrUpdateRelease(releaseName)
337346
if err != nil {
338347
return err

0 commit comments

Comments
 (0)