Fix and improve captions detection (#3276)

This commit is contained in:
puc9
2023-01-26 16:52:56 -08:00
committed by GitHub
parent 08560923d2
commit cf0ce6cb08
3 changed files with 30 additions and 3 deletions

View File

@@ -575,6 +575,23 @@ func (qb *FileStore) find(ctx context.Context, id file.ID) (file.File, error) {
// FindByPath returns the first file that matches the given path. Wildcard characters are supported.
func (qb *FileStore) FindByPath(ctx context.Context, p string) (file.File, error) {
ret, err := qb.FindAllByPath(ctx, p)
if err != nil {
return nil, err
}
if len(ret) == 0 {
return nil, nil
}
return ret[0], nil
}
// FindAllByPath returns all the files that match the given path.
// Wildcard characters are supported.
func (qb *FileStore) FindAllByPath(ctx context.Context, p string) ([]file.File, error) {
// separate basename from path
basename := filepath.Base(p)
dirName := filepath.Dir(p)
@@ -601,7 +618,7 @@ func (qb *FileStore) FindByPath(ctx context.Context, p string) (file.File, error
)
}
ret, err := qb.get(ctx, q)
ret, err := qb.getMany(ctx, q)
if err != nil && !errors.Is(err, sql.ErrNoRows) {
return nil, fmt.Errorf("getting file by path %s: %w", p, err)
}