PollFolders begins the routines to watch folders for changes. if those changes include the addition of compressed files, they are processed for exctraction.
()
| 118 | // if those changes include the addition of compressed files, they |
| 119 | // are processed for exctraction. |
| 120 | func (u *Unpackerr) PollFolders() { |
| 121 | var ( |
| 122 | flist []string |
| 123 | err error |
| 124 | ) |
| 125 | |
| 126 | if isRunningInDocker() && u.Folder.Interval.Duration == 0 { |
| 127 | u.Folder.Interval.Duration = defaultPollInterval |
| 128 | } |
| 129 | |
| 130 | u.Folders, flist = checkFolders(u.Folders, u.Logger) |
| 131 | |
| 132 | u.folders, err = u.Folder.newWatcher(u.Folders, u.Logger) |
| 133 | if err != nil { |
| 134 | u.Errorf("Watching Folders: %s", err) |
| 135 | return |
| 136 | } |
| 137 | // do not close either watcher. |
| 138 | |
| 139 | if len(u.Folders) == 0 { |
| 140 | return |
| 141 | } |
| 142 | |
| 143 | go u.folders.watchFSNotify() |
| 144 | u.Printf("[Folder] Watching (fsnotify): %s", strings.Join(flist, ", ")) |
| 145 | |
| 146 | // Setting an interval of any value less than 5 milliseconds |
| 147 | // (except zero in docker) allows disabling the poller. |
| 148 | if u.Folder.Interval.Duration < minimumPollInterval { |
| 149 | return |
| 150 | } |
| 151 | |
| 152 | go func() { |
| 153 | if err := u.folders.Watcher.Start(u.Folder.Interval.Duration); err != nil { |
| 154 | u.Errorf("Folder poller stopped: %v", err) |
| 155 | } |
| 156 | }() |
| 157 | u.Printf("[Folder] Polling @ %s: %s", u.Folder.Interval.String(), strings.Join(flist, ", ")) |
| 158 | } |
| 159 | |
| 160 | // checkFolders stats all configured folders and returns only "good" ones. |
| 161 | func checkFolders(folders []*FolderConfig, log Logs) ([]*FolderConfig, []string) { |
no test coverage detected