Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: cipd/client/cipd/client.go

Issue 2877643002: [cipd] stop doing weird ownership transfer (Closed)
Patch Set: fix nit Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cipd/client/cipd/client_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cipd/client/cipd/client.go
diff --git a/cipd/client/cipd/client.go b/cipd/client/cipd/client.go
index 9d2f8bb7d9cf767e59beec051697adaf635c8a41..08bbfdc3d0b9113893e8d6641cd99d4f0ad66aa1 100644
--- a/cipd/client/cipd/client.go
+++ b/cipd/client/cipd/client.go
@@ -1272,13 +1272,9 @@ func (client *clientImpl) FetchAndDeployInstance(ctx context.Context, subdir str
return err
}
- // Make sure to close the file if paniced before OpenInstance call below.
- owned := false
defer func() {
- if !owned {
- if err := instanceFile.Close(); err != nil {
- logging.Warningf(ctx, "cipd: failed to close the package file - %s", err)
- }
+ if err := instanceFile.Close(); err != nil && err != os.ErrClosed {
+ logging.Warningf(ctx, "cipd: failed to close the package file - %s", err)
}
}()
@@ -1289,14 +1285,8 @@ func (client *clientImpl) FetchAndDeployInstance(ctx context.Context, subdir str
return err
}
- owned = true // disarm the defer above, instance.Close closes instanceFile.
- defer func() {
- if err := instance.Close(); err != nil {
- logging.Warningf(ctx, "cipd: failed to close the instance - %s", err)
- }
- // Opportunistically clean up trashed files.
- client.doBatchAwareOp(ctx, batchAwareOpCleanupTrash)
- }()
+ // Opportunistically clean up trashed files.
+ defer client.doBatchAwareOp(ctx, batchAwareOpCleanupTrash)
// Deploy it. 'defer' will take care of removing the temp file if needed.
_, err = client.deployer.DeployInstance(ctx, subdir, instance)
« no previous file with comments | « no previous file | cipd/client/cipd/client_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698