MCPcopy Index your code
hub / github.com/devspace-sh/devspace / removeRecursive

Method removeRecursive

helper/server/upstream.go:196–237  ·  view source on GitHub ↗
(absolutePath string)

Source from the content-addressed store, hash-verified

194}
195
196func (u *Upstream) removeRecursive(absolutePath string) error {
197 files, err := os.ReadDir(absolutePath)
198 if err != nil {
199 return err
200 }
201
202 // Loop over directory contents and check if we should delete the contents
203 for _, dirEntry := range files {
204 f, err := dirEntry.Info()
205 if err != nil {
206 continue
207 }
208
209 absoluteChildPath := filepath.Join(absolutePath, f.Name())
210 if fsutil.IsRecursiveSymlink(f, absoluteChildPath) {
211 continue
212 }
213
214 // Check if ignored
215 if u.ignoreMatcher != nil && !u.ignoreMatcher.RequireFullScan() && u.ignoreMatcher.Matches(absolutePath[len(u.options.UploadPath):], f.IsDir()) {
216 continue
217 }
218
219 // Remove recursive
220 if f.IsDir() {
221 // Ignore the errors here
222 _ = u.removeRecursive(absoluteChildPath)
223 } else {
224 // Check if not ignored
225 if u.ignoreMatcher == nil || !u.ignoreMatcher.RequireFullScan() || !u.ignoreMatcher.Matches(absolutePath[len(u.options.UploadPath):], false) {
226 _ = os.Remove(absoluteChildPath)
227 }
228 }
229 }
230
231 // Check if not ignored
232 if u.ignoreMatcher == nil || !u.ignoreMatcher.RequireFullScan() || !u.ignoreMatcher.Matches(absolutePath[len(u.options.UploadPath):], true) {
233 // This will not remove the directory if there is still a file or directory in it
234 return os.Remove(absolutePath)
235 }
236 return nil
237}
238
239// Upload implements the server upload interface and writes all the data received to a
240// temporary file

Callers 1

RemoveMethod · 0.95

Calls 7

IsRecursiveSymlinkFunction · 0.92
NameMethod · 0.65
RequireFullScanMethod · 0.65
MatchesMethod · 0.65
RemoveMethod · 0.65
InfoMethod · 0.45
IsDirMethod · 0.45

Tested by

no test coverage detected