@@ -101,14 +101,14 @@ func (api *API) handleDynamicParameters(rw http.ResponseWriter, r *http.Request,
101
101
102
102
// Add the file first. Calling `Release` if it fails is a no-op, so this is safe.
103
103
templateFS , err := api .FileCache .Acquire (fileCtx , fileID )
104
- defer api .FileCache .Release (fileID )
105
104
if err != nil {
106
105
httpapi .Write (ctx , rw , http .StatusNotFound , codersdk.Response {
107
106
Message : "Internal error fetching template version Terraform." ,
108
107
Detail : err .Error (),
109
108
})
110
109
return
111
110
}
111
+ defer api .FileCache .Release (fileID )
112
112
113
113
// Having the Terraform plan available for the evaluation engine is helpful
114
114
// for populating values from data blocks, but isn't strictly required. If
@@ -120,14 +120,14 @@ func (api *API) handleDynamicParameters(rw http.ResponseWriter, r *http.Request,
120
120
121
121
if tf .CachedModuleFiles .Valid {
122
122
moduleFilesFS , err := api .FileCache .Acquire (fileCtx , tf .CachedModuleFiles .UUID )
123
- defer api .FileCache .Release (tf .CachedModuleFiles .UUID )
124
123
if err != nil {
125
124
httpapi .Write (ctx , rw , http .StatusNotFound , codersdk.Response {
126
125
Message : "Internal error fetching Terraform modules." ,
127
126
Detail : err .Error (),
128
127
})
129
128
return
130
129
}
130
+ defer api .FileCache .Release (tf .CachedModuleFiles .UUID )
131
131
132
132
templateFS = files .NewOverlayFS (templateFS , []files.Overlay {{Path : ".terraform/modules" , FS : moduleFilesFS }})
133
133
}
0 commit comments