예제 #1
0
파일: status.go 프로젝트: peer23peer/TMSU
func statusDatabase(store *storage.Storage, tx *storage.Tx, dirOnly, followSymlinks bool) (*StatusReport, error) {
	report := NewReport()

	log.Info(2, "retrieving all files from database.")

	files, err := store.Files(tx, "name")
	if err != nil {
		return nil, fmt.Errorf("could not retrieve files: %v", err)
	}

	err = statusCheckFiles(files, report)
	if err != nil {
		return nil, err
	}

	tree := _path.NewTree()
	for _, file := range files {
		tree.Add(file.Path(), file.IsDir)
	}

	topLevelPaths := tree.TopLevel().Paths()
	if err != nil {
		return nil, err
	}

	for _, path := range topLevelPaths {
		if err = findNewFiles(path, report, dirOnly, followSymlinks); err != nil {
			return nil, err
		}
	}

	return report, nil
}