starting to write the commit functions
This commit is contained in:
@@ -39,17 +39,20 @@ func (db *DB) CheckIfFileCurrentlyMonitored(path string) bool {
|
||||
if err := db.One("Path", path, &file); err != nil {
|
||||
if err.Error() != "not found" {
|
||||
db.Err(err).Msg("Error finding file by path")
|
||||
fmt.Printf("Not found: %s error: %s\n", path, err)
|
||||
return false
|
||||
}
|
||||
db.Warn().Msg("no file found")
|
||||
fmt.Printf("Not found: %s error: %s\n", path, err)
|
||||
return false
|
||||
}
|
||||
fmt.Printf("Found!: %s searched: %s\n", file.Path, path)
|
||||
return true
|
||||
}
|
||||
|
||||
// RetrieveWatchedFiles all files that are in the database as "watched files"
|
||||
// RetrieveTrackedFiles all files that are in the database as "watched files"
|
||||
// This can be used to trigger the same files to be watched again
|
||||
func (db *DB) RetrieveWatchedFiles() ([]File, error) {
|
||||
func (db *DB) RetrieveTrackedFiles() ([]File, error) {
|
||||
var files []File
|
||||
if err := db.All(&files); err != nil {
|
||||
db.Err(err).Msg("Error retrieving all watched files")
|
||||
|
@@ -105,7 +105,6 @@ func (m *Manager) AddFileToRepo(relFilePath string) error {
|
||||
// f := NewFileManager()
|
||||
//DELAYED: this feature affects only large files and user experience. It can wait.
|
||||
relFilePath = strings.TrimSpace(relFilePath) //purging any odd spaces TODO: Make sure not needed
|
||||
fmt.Println("Checking for file: ", relFilePath)
|
||||
var tmpFile database.File
|
||||
filename := filepath.Base(relFilePath)
|
||||
var hash [16]byte
|
||||
@@ -160,3 +159,12 @@ func (m *Manager) prepareDatabaseForFile(tmpFile database.File) (int, error) {
|
||||
return fileID, nil
|
||||
|
||||
}
|
||||
|
||||
// FetchTrackedFiles just grabbes all the files currently tracked in the repo
|
||||
func (m *Manager) FetchTrackedFiles() ([]database.File, error) {
|
||||
files, err := m.dB.RetrieveTrackedFiles()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to retrieve tracked files: %s", err)
|
||||
}
|
||||
return files, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user