(dir string)
| 28 | type ApplicationFiles struct{} |
| 29 | |
| 30 | func (appfiles ApplicationFiles) AppFilesInDir(dir string) ([]models.AppFileFields, error) { |
| 31 | appFiles := []models.AppFileFields{} |
| 32 | |
| 33 | fullDirPath, toplevelErr := filepath.Abs(dir) |
| 34 | if toplevelErr != nil { |
| 35 | return appFiles, toplevelErr |
| 36 | } |
| 37 | |
| 38 | toplevelErr = appfiles.WalkAppFiles(fullDirPath, func(fileName string, fullPath string) error { |
| 39 | fileInfo, err := os.Lstat(fullPath) |
| 40 | if err != nil { |
| 41 | return err |
| 42 | } |
| 43 | |
| 44 | appFile := models.AppFileFields{ |
| 45 | Path: filepath.ToSlash(fileName), |
| 46 | Size: fileInfo.Size(), |
| 47 | } |
| 48 | |
| 49 | if fileInfo.IsDir() { |
| 50 | appFile.Sha1 = "0" |
| 51 | appFile.Size = 0 |
| 52 | } else { |
| 53 | sha, err := appfiles.shaFile(fullPath) |
| 54 | if err != nil { |
| 55 | return err |
| 56 | } |
| 57 | appFile.Sha1 = sha |
| 58 | } |
| 59 | |
| 60 | appFiles = append(appFiles, appFile) |
| 61 | |
| 62 | return nil |
| 63 | }) |
| 64 | |
| 65 | return appFiles, toplevelErr |
| 66 | } |
| 67 | |
| 68 | func (appfiles ApplicationFiles) shaFile(fullPath string) (string, error) { |
| 69 | hash := sha1.New() |
nothing calls this directly
no test coverage detected