RegisterFileInHistory check if file is already known and hasn't change in files history return true if file is append to history and false if it is already known as is.
(f os.FileInfo, path string, history *[]FileDescriptor, verbose bool)
| 8 | |
| 9 | // RegisterFileInHistory check if file is already known and hasn't change in files history return true if file is append to history and false if it is already known as is. |
| 10 | func RegisterFileInHistory(f os.FileInfo, path string, history *[]FileDescriptor, verbose bool) bool { |
| 11 | if int(f.Size()) > 1024*1024*maxFilesizeScan { |
| 12 | if verbose { |
| 13 | logMessage(LOG_INFO, "[INFO]", path, "skipped - larger than", maxFilesizeScan, "Mb") |
| 14 | } |
| 15 | return true |
| 16 | } |
| 17 | |
| 18 | for i, h := range *history { |
| 19 | if h.FilePath == path { |
| 20 | if h.LastModified == f.ModTime() && h.FileSize == f.Size() { |
| 21 | return false |
| 22 | } |
| 23 | (*history)[i].LastModified = f.ModTime() |
| 24 | (*history)[i].FileSize = f.Size() |
| 25 | return true |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | var d = FileDescriptor{FilePath: path, FileSize: f.Size(), LastModified: f.ModTime()} |
| 30 | *history = append(*history, d) |
| 31 | return true |
| 32 | } |
| 33 | |
| 34 | // StringInSlice check wether or not a string already is inside a specified slice |
| 35 | func StringInSlice(a string, list []string) bool { |
no test coverage detected