mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-08-16 22:07:39 +00:00
get nickname from seahub database (#663)
* Add parse seahub database config * Get nickname from seahub database * Go get nickname from seahub database * Save output of script to memory and fix some errors * Add exec permission and free child_output --------- Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
parent
49168a140c
commit
d51591d8f7
@ -14,9 +14,9 @@ endif
|
|||||||
|
|
||||||
MAKE_SERVER = server tools $(MAKE_CONTROLLER) $(MAKE_FUSE)
|
MAKE_SERVER = server tools $(MAKE_CONTROLLER) $(MAKE_FUSE)
|
||||||
|
|
||||||
SUBDIRS = include lib common python $(MAKE_SERVER) doc
|
SUBDIRS = include lib common python $(MAKE_SERVER) doc scripts
|
||||||
|
|
||||||
DIST_SUBDIRS = include lib common python server tools controller fuse doc
|
DIST_SUBDIRS = include lib common python server tools controller fuse doc scripts
|
||||||
|
|
||||||
INTLTOOL = \
|
INTLTOOL = \
|
||||||
intltool-extract.in \
|
intltool-extract.in \
|
||||||
|
@ -13,6 +13,31 @@ merge_trees_recursive (const char *store_id, int version,
|
|||||||
const char *basedir,
|
const char *basedir,
|
||||||
MergeOptions *opt);
|
MergeOptions *opt);
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
get_nickname_by_modifier (GHashTable *email_to_nickname, const char *modifier)
|
||||||
|
{
|
||||||
|
const char *nickname = NULL;
|
||||||
|
|
||||||
|
if (!modifier) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
nickname = g_hash_table_lookup (email_to_nickname, modifier);
|
||||||
|
if (nickname) {
|
||||||
|
return nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *sql = "SELECT nickname from profile_profile WHERE user = ?";
|
||||||
|
nickname = seaf_db_statement_get_string(seaf->seahub_db, sql, 1, "string", modifier);
|
||||||
|
|
||||||
|
if (!nickname) {
|
||||||
|
nickname = modifier;
|
||||||
|
}
|
||||||
|
g_hash_table_insert (email_to_nickname, g_strdup(modifier), g_strdup(nickname));
|
||||||
|
|
||||||
|
return nickname;
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
merge_conflict_filename (const char *store_id, int version,
|
merge_conflict_filename (const char *store_id, int version,
|
||||||
MergeOptions *opt,
|
MergeOptions *opt,
|
||||||
@ -20,6 +45,7 @@ merge_conflict_filename (const char *store_id, int version,
|
|||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
char *path = NULL, *modifier = NULL, *conflict_name = NULL;
|
char *path = NULL, *modifier = NULL, *conflict_name = NULL;
|
||||||
|
const char *nickname = NULL;
|
||||||
gint64 mtime;
|
gint64 mtime;
|
||||||
SeafCommit *commit;
|
SeafCommit *commit;
|
||||||
|
|
||||||
@ -46,7 +72,11 @@ merge_conflict_filename (const char *store_id, int version,
|
|||||||
seaf_commit_unref (commit);
|
seaf_commit_unref (commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
conflict_name = gen_conflict_path (filename, modifier, mtime);
|
nickname = modifier;
|
||||||
|
if (seaf->seahub_db)
|
||||||
|
nickname = get_nickname_by_modifier (opt->email_to_nickname, modifier);
|
||||||
|
|
||||||
|
conflict_name = gen_conflict_path (filename, nickname, mtime);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free (path);
|
g_free (path);
|
||||||
@ -61,6 +91,7 @@ merge_conflict_dirname (const char *store_id, int version,
|
|||||||
const char *dirname)
|
const char *dirname)
|
||||||
{
|
{
|
||||||
char *modifier = NULL, *conflict_name = NULL;
|
char *modifier = NULL, *conflict_name = NULL;
|
||||||
|
const char *nickname = NULL;
|
||||||
SeafCommit *commit;
|
SeafCommit *commit;
|
||||||
|
|
||||||
commit = seaf_commit_manager_get_commit (seaf->commit_mgr,
|
commit = seaf_commit_manager_get_commit (seaf->commit_mgr,
|
||||||
@ -74,7 +105,11 @@ merge_conflict_dirname (const char *store_id, int version,
|
|||||||
modifier = g_strdup(commit->creator_name);
|
modifier = g_strdup(commit->creator_name);
|
||||||
seaf_commit_unref (commit);
|
seaf_commit_unref (commit);
|
||||||
|
|
||||||
conflict_name = gen_conflict_path (dirname, modifier, (gint64)time(NULL));
|
nickname = modifier;
|
||||||
|
if (seaf->seahub_db)
|
||||||
|
nickname = get_nickname_by_modifier (opt->email_to_nickname, modifier);
|
||||||
|
|
||||||
|
conflict_name = gen_conflict_path (dirname, nickname, (gint64)time(NULL));
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free (modifier);
|
g_free (modifier);
|
||||||
@ -687,6 +722,11 @@ seaf_merge_trees (const char *store_id, int version,
|
|||||||
|
|
||||||
g_return_val_if_fail (n == 2 || n == 3, -1);
|
g_return_val_if_fail (n == 2 || n == 3, -1);
|
||||||
|
|
||||||
|
opt->email_to_nickname = g_hash_table_new_full(g_str_hash,
|
||||||
|
g_str_equal,
|
||||||
|
g_free,
|
||||||
|
g_free);
|
||||||
|
|
||||||
trees = g_new0 (SeafDir *, n);
|
trees = g_new0 (SeafDir *, n);
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
root = seaf_fs_manager_get_seafdir (seaf->fs_mgr, store_id, version, roots[i]);
|
root = seaf_fs_manager_get_seafdir (seaf->fs_mgr, store_id, version, roots[i]);
|
||||||
@ -704,5 +744,7 @@ seaf_merge_trees (const char *store_id, int version,
|
|||||||
seaf_dir_free (trees[i]);
|
seaf_dir_free (trees[i]);
|
||||||
g_free (trees);
|
g_free (trees);
|
||||||
|
|
||||||
|
g_hash_table_destroy (opt->email_to_nickname);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ typedef struct MergeOptions {
|
|||||||
char merged_tree_root[41]; /* merge result */
|
char merged_tree_root[41]; /* merge result */
|
||||||
int visit_dirs;
|
int visit_dirs;
|
||||||
gboolean conflict;
|
gboolean conflict;
|
||||||
|
|
||||||
|
GHashTable *email_to_nickname;
|
||||||
} MergeOptions;
|
} MergeOptions;
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -379,3 +379,129 @@ load_ccnet_database_config (SeafileSession *session)
|
|||||||
g_free (engine);
|
g_free (engine);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
parse_seahub_db_config ()
|
||||||
|
{
|
||||||
|
char buf[1024];
|
||||||
|
GError *error = NULL;
|
||||||
|
int retcode = 0;
|
||||||
|
char *child_stdout = NULL;
|
||||||
|
char *child_stderr = NULL;
|
||||||
|
|
||||||
|
char *binary_path = g_find_program_in_path ("parse_seahub_db.py");
|
||||||
|
|
||||||
|
snprintf (buf,
|
||||||
|
sizeof(buf),
|
||||||
|
"python3 %s",
|
||||||
|
binary_path);
|
||||||
|
g_spawn_command_line_sync (buf,
|
||||||
|
&child_stdout,
|
||||||
|
&child_stderr,
|
||||||
|
&retcode,
|
||||||
|
&error);
|
||||||
|
|
||||||
|
if (error != NULL) {
|
||||||
|
seaf_warning ("Failed to run python parse_seahub_db.py: %s\n", error->message);
|
||||||
|
g_free (binary_path);
|
||||||
|
g_free (child_stdout);
|
||||||
|
g_free (child_stderr);
|
||||||
|
g_clear_error (&error);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
g_spawn_check_exit_status (retcode, &error);
|
||||||
|
if (error != NULL) {
|
||||||
|
seaf_warning ("Failed to run python parse_seahub_db.py: %s\n", error->message);
|
||||||
|
g_free (binary_path);
|
||||||
|
g_free (child_stdout);
|
||||||
|
g_free (child_stderr);
|
||||||
|
g_clear_error (&error);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (binary_path);
|
||||||
|
g_free (child_stderr);
|
||||||
|
return child_stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
load_seahub_database_config (SeafileSession *session)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
json_t *object = NULL;
|
||||||
|
json_error_t err;
|
||||||
|
const char *engine = NULL, *name = NULL, *user = NULL, *password = NULL, *host = NULL, *charset = NULL;
|
||||||
|
int port;
|
||||||
|
char *json_str = NULL;
|
||||||
|
|
||||||
|
json_str = parse_seahub_db_config ();
|
||||||
|
if (!json_str){
|
||||||
|
seaf_warning ("Failed to parse seahub database config.\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
object = json_loadb (json_str, strlen(json_str), 0, &err);
|
||||||
|
if (!object) {
|
||||||
|
seaf_warning ("Failed to load seahub db json: %s: %s\n", json_str, err.text);
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
engine = json_object_get_string_member (object, "ENGINE");
|
||||||
|
name = json_object_get_string_member (object, "NAME");
|
||||||
|
user = json_object_get_string_member (object, "USER");
|
||||||
|
password = json_object_get_string_member (object, "PASSWORD");
|
||||||
|
host = json_object_get_string_member (object, "HOST");
|
||||||
|
charset = json_object_get_string_member (object, "CHARSET");
|
||||||
|
port = json_object_get_int_member (object, "PORT");
|
||||||
|
if (port <= 0) {
|
||||||
|
port = MYSQL_DEFAULT_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!engine || strstr (engine, "sqlite") != NULL) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_MYSQL
|
||||||
|
else if (strstr (engine, "mysql") != NULL) {
|
||||||
|
seaf_message("Use database Mysql\n");
|
||||||
|
if (!host) {
|
||||||
|
seaf_warning ("Seahub DB host not set in config.\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (!user) {
|
||||||
|
seaf_warning ("Seahub DB user not set in config.\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (!password) {
|
||||||
|
seaf_warning ("Seahub DB password not set in config.\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (!name) {
|
||||||
|
seaf_warning ("Seahub DB name not set in config.\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
session->seahub_db = seaf_db_new_mysql (host, port, user, password, name, NULL, FALSE, FALSE, NULL, charset, DEFAULT_MAX_CONNECTIONS);
|
||||||
|
if (!session->seahub_db) {
|
||||||
|
seaf_warning ("Failed to open seahub database.\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
seaf_warning ("Unknown database type: %s.\n", engine);
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (object)
|
||||||
|
json_decref (object);
|
||||||
|
g_free (json_str);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -16,4 +16,7 @@ load_database_config (struct _SeafileSession *session);
|
|||||||
int
|
int
|
||||||
load_ccnet_database_config (struct _SeafileSession *session);
|
load_ccnet_database_config (struct _SeafileSession *session);
|
||||||
|
|
||||||
|
int
|
||||||
|
load_seahub_database_config (SeafileSession *session);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -317,6 +317,7 @@ AC_CONFIG_FILES(
|
|||||||
controller/Makefile
|
controller/Makefile
|
||||||
tools/Makefile
|
tools/Makefile
|
||||||
doc/Makefile
|
doc/Makefile
|
||||||
|
scripts/Makefile
|
||||||
)
|
)
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
@ -5,15 +5,18 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@ -41,7 +44,7 @@ var pidFilePath string
|
|||||||
var logFp *os.File
|
var logFp *os.File
|
||||||
|
|
||||||
var dbType string
|
var dbType string
|
||||||
var seafileDB, ccnetDB *sql.DB
|
var seafileDB, ccnetDB, seahubDB *sql.DB
|
||||||
|
|
||||||
// when SQLite is used, user and group db are separated.
|
// when SQLite is used, user and group db are separated.
|
||||||
var userDB, groupDB *sql.DB
|
var userDB, groupDB *sql.DB
|
||||||
@ -269,6 +272,69 @@ func loadSeafileDB() {
|
|||||||
dbType = dbEngine
|
dbType = dbEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loadSeahubDB() {
|
||||||
|
scriptPath, err := exec.LookPath("parse_seahub_db.py")
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to find script of parse_seahub_db.py: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd := exec.Command("python3", scriptPath)
|
||||||
|
dbData, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to run python parse_seahub_db.py: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dbConfig := make(map[string]string)
|
||||||
|
|
||||||
|
err = json.Unmarshal(dbData, &dbConfig)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to decode seahub database json file: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dbEngine := dbConfig["ENGINE"]
|
||||||
|
dbName := dbConfig["NAME"]
|
||||||
|
user := dbConfig["USER"]
|
||||||
|
password := dbConfig["PASSWORD"]
|
||||||
|
host := dbConfig["HOST"]
|
||||||
|
portStr := dbConfig["PORT"]
|
||||||
|
|
||||||
|
if strings.Index(dbEngine, "mysql") >= 0 {
|
||||||
|
port, err := strconv.ParseInt(portStr, 10, 64)
|
||||||
|
if err != nil || port <= 0 {
|
||||||
|
port = 3306
|
||||||
|
}
|
||||||
|
if dbName == "" {
|
||||||
|
log.Warnf("Seahub DB name not set in config")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if user == "" {
|
||||||
|
log.Warnf("Seahub DB user not set in config")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if password == "" {
|
||||||
|
log.Warnf("Seahub DB password not set in config")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if host == "" {
|
||||||
|
log.Warnf("Seahub DB host not set in config")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?tls=%t", user, password, host, port, dbName, false)
|
||||||
|
|
||||||
|
seahubDB, err = sql.Open("mysql", dsn)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to open database: %v", err)
|
||||||
|
}
|
||||||
|
} else if strings.Index(dbEngine, "sqlite") >= 0 {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
log.Warnf("Unsupported database %s.", dbEngine)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func writePidFile(pid_file_path string) error {
|
func writePidFile(pid_file_path string) error {
|
||||||
file, err := os.OpenFile(pid_file_path, os.O_CREATE|os.O_WRONLY, 0664)
|
file, err := os.OpenFile(pid_file_path, os.O_CREATE|os.O_WRONLY, 0664)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -367,6 +433,8 @@ func main() {
|
|||||||
fp.Close()
|
fp.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadSeahubDB()
|
||||||
|
|
||||||
repomgr.Init(seafileDB)
|
repomgr.Init(seafileDB)
|
||||||
|
|
||||||
fsmgr.Init(centralDir, dataDir, option.FsCacheLimit)
|
fsmgr.Init(centralDir, dataDir, option.FsCacheLimit)
|
||||||
|
@ -12,10 +12,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type mergeOptions struct {
|
type mergeOptions struct {
|
||||||
remoteRepoID string
|
remoteRepoID string
|
||||||
remoteHead string
|
remoteHead string
|
||||||
mergedRoot string
|
mergedRoot string
|
||||||
conflict bool
|
conflict bool
|
||||||
|
emailToNickname map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func mergeTrees(storeID string, roots []string, opt *mergeOptions) error {
|
func mergeTrees(storeID string, roots []string, opt *mergeOptions) error {
|
||||||
@ -24,6 +25,8 @@ func mergeTrees(storeID string, roots []string, opt *mergeOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opt.emailToNickname = make(map[string]string)
|
||||||
|
|
||||||
var trees []*fsmgr.SeafDir
|
var trees []*fsmgr.SeafDir
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
dir, err := fsmgr.GetSeafdir(storeID, roots[i])
|
dir, err := fsmgr.GetSeafdir(storeID, roots[i])
|
||||||
@ -335,7 +338,9 @@ func mergeConflictFileName(storeID string, opt *mergeOptions, baseDir, fileName
|
|||||||
mtime = time.Now().Unix()
|
mtime = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
conflictName := genConflictPath(fileName, modifier, mtime)
|
nickname := getNickNameByModifier(opt.emailToNickname, modifier)
|
||||||
|
|
||||||
|
conflictName := genConflictPath(fileName, nickname, mtime)
|
||||||
|
|
||||||
return conflictName, nil
|
return conflictName, nil
|
||||||
}
|
}
|
||||||
@ -366,6 +371,29 @@ func genConflictPath(originPath, modifier string, mtime int64) string {
|
|||||||
return conflictPath
|
return conflictPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getNickNameByModifier(emailToNickname map[string]string, modifier string) string {
|
||||||
|
if modifier == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
nickname, ok := emailToNickname[modifier]
|
||||||
|
if ok {
|
||||||
|
return nickname
|
||||||
|
}
|
||||||
|
if seahubDB != nil {
|
||||||
|
sqlStr := "SELECT nickname from profile_profile WHERE user = ?"
|
||||||
|
row := seahubDB.QueryRow(sqlStr, modifier)
|
||||||
|
row.Scan(&nickname)
|
||||||
|
}
|
||||||
|
|
||||||
|
if nickname == "" {
|
||||||
|
nickname = modifier
|
||||||
|
}
|
||||||
|
|
||||||
|
emailToNickname[modifier] = nickname
|
||||||
|
|
||||||
|
return nickname
|
||||||
|
}
|
||||||
|
|
||||||
func getFileModifierMtime(repoID, storeID, head, filePath string) (string, int64, error) {
|
func getFileModifierMtime(repoID, storeID, head, filePath string) (string, int64, error) {
|
||||||
commit, err := commitmgr.Load(repoID, head)
|
commit, err := commitmgr.Load(repoID, head)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -30,24 +30,27 @@ var mergeTestTree4CommitID string
|
|||||||
var mergeTestTree5CommitID string
|
var mergeTestTree5CommitID string
|
||||||
|
|
||||||
/*
|
/*
|
||||||
test directory structure:
|
test directory structure:
|
||||||
tree1
|
tree1
|
||||||
|--bbb
|
|--bbb
|
||||||
|-- testfile(size:1)
|
|
||||||
|
|
||||||
tree2
|
|-- testfile(size:1)
|
||||||
|--bbb
|
|
||||||
|-- testfile(size:10)
|
|
||||||
|
|
||||||
tree3
|
tree2
|
||||||
|--bbb
|
|--bbb
|
||||||
|
|
||||||
tree4
|
|-- testfile(size:10)
|
||||||
|--bbb
|
|
||||||
|-- testfile(size:100)
|
|
||||||
|
|
||||||
tree5
|
tree3
|
||||||
|--
|
|--bbb
|
||||||
|
|
||||||
|
tree4
|
||||||
|
|--bbb
|
||||||
|
|
||||||
|
|-- testfile(size:100)
|
||||||
|
|
||||||
|
tree5
|
||||||
|
|--
|
||||||
*/
|
*/
|
||||||
func mergeTestCreateTestDir() error {
|
func mergeTestCreateTestDir() error {
|
||||||
modeDir := uint32(syscall.S_IFDIR | 0644)
|
modeDir := uint32(syscall.S_IFDIR | 0644)
|
||||||
|
@ -26,6 +26,7 @@ struct _SeafileSession {
|
|||||||
GKeyFile *ccnet_config;
|
GKeyFile *ccnet_config;
|
||||||
SeafDB *db;
|
SeafDB *db;
|
||||||
SeafDB *ccnet_db;
|
SeafDB *ccnet_db;
|
||||||
|
SeafDB *seahub_db;
|
||||||
|
|
||||||
SeafBlockManager *block_mgr;
|
SeafBlockManager *block_mgr;
|
||||||
SeafFSManager *fs_mgr;
|
SeafFSManager *fs_mgr;
|
||||||
|
3
scripts/Makefile.am
Normal file
3
scripts/Makefile.am
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
bin_SCRIPTS = parse_seahub_db.py
|
||||||
|
|
||||||
|
EXTRA_DIST = parse_seahub_db.py
|
6
scripts/parse_seahub_db.py
Executable file
6
scripts/parse_seahub_db.py
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
import json
|
||||||
|
import seahub_settings
|
||||||
|
|
||||||
|
db_infos = seahub_settings.DATABASES['default']
|
||||||
|
|
||||||
|
print(json.dumps(db_infos))
|
@ -24,6 +24,7 @@ struct _SeafileSession {
|
|||||||
GKeyFile *ccnet_config;
|
GKeyFile *ccnet_config;
|
||||||
SeafDB *db;
|
SeafDB *db;
|
||||||
SeafDB *ccnet_db;
|
SeafDB *ccnet_db;
|
||||||
|
SeafDB *seahub_db;
|
||||||
|
|
||||||
SeafBlockManager *block_mgr;
|
SeafBlockManager *block_mgr;
|
||||||
SeafFSManager *fs_mgr;
|
SeafFSManager *fs_mgr;
|
||||||
|
@ -218,6 +218,8 @@ seafile_session_new(const char *central_config_dir,
|
|||||||
goto onerror;
|
goto onerror;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load_seahub_database_config (session);
|
||||||
|
|
||||||
session->cfg_mgr = seaf_cfg_manager_new (session);
|
session->cfg_mgr = seaf_cfg_manager_new (session);
|
||||||
if (!session->cfg_mgr)
|
if (!session->cfg_mgr)
|
||||||
goto onerror;
|
goto onerror;
|
||||||
|
@ -47,6 +47,7 @@ struct _SeafileSession {
|
|||||||
GKeyFile *ccnet_config;
|
GKeyFile *ccnet_config;
|
||||||
SeafDB *db;
|
SeafDB *db;
|
||||||
CcnetDB *ccnet_db;
|
CcnetDB *ccnet_db;
|
||||||
|
SeafDB *seahub_db;
|
||||||
|
|
||||||
SeafBlockManager *block_mgr;
|
SeafBlockManager *block_mgr;
|
||||||
SeafFSManager *fs_mgr;
|
SeafFSManager *fs_mgr;
|
||||||
|
Loading…
Reference in New Issue
Block a user