sql providers: add a query timeout

This commit is contained in:
Nicola Murino
2020-07-08 18:54:44 +02:00
parent 790c11c453
commit 42877dd915
4 changed files with 141 additions and 84 deletions

View File

@@ -3,6 +3,7 @@
package dataprovider
import (
"context"
"database/sql"
"fmt"
"strings"
@@ -139,7 +140,9 @@ func (p PGSQLProvider) getFolders(limit, offset int, order, folderPath string) (
}
func (p PGSQLProvider) getFolderByPath(mappedPath string) (vfs.BaseVirtualFolder, error) {
return sqlCommonCheckFolderExists(mappedPath, p.dbHandle)
ctx, cancel := context.WithTimeout(context.Background(), defaultSQLQueryTimeout)
defer cancel()
return sqlCommonCheckFolderExists(ctx, mappedPath, p.dbHandle)
}
func (p PGSQLProvider) addFolder(folder vfs.BaseVirtualFolder) error {