working on adding files to repo and making sure no duplicates

This commit is contained in:
2020-06-19 22:57:42 -04:00
parent e75991da22
commit 47cc65a824
7 changed files with 113 additions and 67 deletions

View File

@@ -33,19 +33,18 @@ func (db *DB) ConfigureDB(dbPath string) error {
// CheckIfFileCurrentlyMonitored checks if the file is already being monitored. This is a read-only check
// to see whether the file was correctly initialised
// (BUG) The hash causes the same file to be in database multiple times!
func (db *DB) CheckIfFileCurrentlyMonitored(src string, hash [16]byte) (File, error) {
func (db *DB) CheckIfFileCurrentlyMonitored(path string) bool {
var file File
//TODO: check this actually works still (don't need hash passed to this anymore)
if err := db.One("Path", src, &file); err != nil {
if err := db.One("Path", path, &file); err != nil {
if err.Error() != "not found" {
db.Err(err).Msg("Error finding file by path")
return File{}, err
return false
}
db.Warn().Msg("no file found")
return File{}, err
return false
}
return file, nil
return true
}
// RetrieveWatchedFiles all files that are in the database as "watched files"