1
0
mirror of https://github.com/drakkan/sftpgo.git synced 2025-11-29 22:08:10 +02:00

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"
@@ -140,7 +141,9 @@ func (p MySQLProvider) getFolders(limit, offset int, order, folderPath string) (
}
func (p MySQLProvider) 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 MySQLProvider) addFolder(folder vfs.BaseVirtualFolder) error {