(username, directory string)
| 260 | } |
| 261 | |
| 262 | func processDirectory(username, directory string) { |
| 263 | // Look for crontab files in the system drop-in directory but only prompt to import them |
| 264 | // if the directory is writable for this user. |
| 265 | files := lib.EnumerateFiles(directory) |
| 266 | if len(files) > 0 { |
| 267 | testCrontab := lib.CrontabFactory(username, files[0]) |
| 268 | if !testCrontab.IsWritable() { |
| 269 | printWarningText(fmt.Sprintf("Directory %s is not writable. Re-run command with sudo. Skipping", directory), false) |
| 270 | return |
| 271 | } |
| 272 | |
| 273 | for _, crontabFile := range files { |
| 274 | if userAbortedSync { |
| 275 | break |
| 276 | } |
| 277 | if importedCrontabs > 0 { |
| 278 | printLn() |
| 279 | } |
| 280 | |
| 281 | if processCrontab(lib.CrontabFactory(username, crontabFile)) { |
| 282 | importedCrontabs++ |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | // importMonitorsFromFile imports monitors from a YAML or JSON file |
| 289 | // YAML files are sent with Content-Type: application/yaml |
no test coverage detected