Skip to content

Commit

Permalink
Go read database config from seafile.conf and env
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Nov 4, 2024
1 parent 5e4fd24 commit 6d0c091
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 162 deletions.
6 changes: 6 additions & 0 deletions common/seaf-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,16 @@ load_db_option_from_env (DBOption *option)
if (env_ccnet_db) {
g_free (option->ccnet_db_name);
option->ccnet_db_name = g_strdup (env_ccnet_db);
} else if (!option->ccnet_db_name) {
option->ccnet_db_name = g_strdup ("ccnet_db");
seaf_message ("Failed to read SEAFILE_MYSQL_DB_CCNET_DB_NAME, use ccnet_db by default");
}
if (env_seafile_db) {
g_free (option->seafile_db_name);
option->seafile_db_name = g_strdup (env_seafile_db);
} else if (!option->seafile_db_name) {
option->seafile_db_name = g_strdup ("seafile_db");
seaf_message ("Failed to read SEAFILE_MYSQL_DB_SEAFILE_DB_NAME, use seafile_db by default");
}

return 0;
Expand Down
6 changes: 1 addition & 5 deletions fileserver/fileop.go
Original file line number Diff line number Diff line change
Expand Up @@ -2077,11 +2077,7 @@ func updateBranch(repoID, originRepoID, newCommitID, oldCommitID, secondParentID

var commitID string
name := "master"
if strings.EqualFold(dbType, "mysql") {
sqlStr = "SELECT commit_id FROM Branch WHERE name = ? AND repo_id = ? FOR UPDATE"
} else {
sqlStr = "SELECT commit_id FROM Branch WHERE name = ? AND repo_id = ?"
}
sqlStr = "SELECT commit_id FROM Branch WHERE name = ? AND repo_id = ? FOR UPDATE"

row = trans.QueryRowContext(ctx, sqlStr, name, repoID)
if err := row.Scan(&commitID); err != nil {
Expand Down
Loading

0 comments on commit 6d0c091

Please sign in to comment.