(absolutePath string)
| 194 | } |
| 195 | |
| 196 | func (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 |
no test coverage detected