Skip to content

Commit 5718855

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

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/push/push.go

Lines changed: 9 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
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy