New functions to get file by path
This commit is contained in:
parent
99975d9df4
commit
b84fe87f48
|
@ -49,6 +49,17 @@ func GetFiles() ([]EFile, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func GetFileByPath(path string) (EFile, error) {
|
||||
path = strings.TrimPrefix(path, FilesDir)
|
||||
|
||||
var f EFile
|
||||
if err := DBQueryRow("SELECT id_file, origin, path, name, cksum, size FROM exercice_files WHERE path = ?", path).Scan(&f.Id, &f.origin, &f.Path, &f.Name, &f.Checksum, &f.Size); err != nil {
|
||||
return f, err
|
||||
}
|
||||
|
||||
return f, nil
|
||||
}
|
||||
|
||||
func (e Exercice) GetFiles() ([]EFile, error) {
|
||||
if rows, err := DBQuery("SELECT id_file, origin, path, name, cksum, size FROM exercice_files WHERE id_exercice = ?", e.Id); err != nil {
|
||||
return nil, err
|
||||
|
@ -72,6 +83,17 @@ func (e Exercice) GetFiles() ([]EFile, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func (e Exercice) GetFileByPath(path string) (EFile, error) {
|
||||
path = strings.TrimPrefix(path, FilesDir)
|
||||
|
||||
var f EFile
|
||||
if err := DBQueryRow("SELECT id_file, origin, path, name, cksum, size FROM exercice_files WHERE id_exercice = ? AND path = ?", e.Id, path).Scan(&f.Id, &f.origin, &f.Path, &f.Name, &f.Checksum, &f.Size); err != nil {
|
||||
return f, err
|
||||
}
|
||||
|
||||
return f, nil
|
||||
}
|
||||
|
||||
func (e Exercice) ImportFile(filePath string, origin string, digest []byte) (interface{}, error) {
|
||||
if digest == nil && !OptionalDigest {
|
||||
return EFile{}, errors.New("No digest given.")
|
||||
|
|
Loading…
Reference in New Issue
Block a user