mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
initprovider: check if the provider is already initialized
exit with code 0 if no initialization is required
This commit is contained in:
@@ -766,7 +766,7 @@ func sqlCommonRollbackTransaction(tx *sql.Tx) {
|
||||
}
|
||||
}
|
||||
|
||||
func sqlCommonGetDatabaseVersion(dbHandle *sql.DB) (schemaVersion, error) {
|
||||
func sqlCommonGetDatabaseVersion(dbHandle *sql.DB, showInitWarn bool) (schemaVersion, error) {
|
||||
var result schemaVersion
|
||||
ctx, cancel := context.WithTimeout(context.Background(), defaultSQLQueryTimeout)
|
||||
defer cancel()
|
||||
@@ -774,7 +774,7 @@ func sqlCommonGetDatabaseVersion(dbHandle *sql.DB) (schemaVersion, error) {
|
||||
stmt, err := dbHandle.PrepareContext(ctx, q)
|
||||
if err != nil {
|
||||
providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err)
|
||||
if strings.Contains(err.Error(), sqlTableSchemaVersion) {
|
||||
if showInitWarn && strings.Contains(err.Error(), sqlTableSchemaVersion) {
|
||||
logger.WarnToConsole("database query error, did you forgot to run the \"initprovider\" command?")
|
||||
}
|
||||
return result, err
|
||||
|
||||
Reference in New Issue
Block a user