1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-07-31 06:49:58 +00:00

Merge branch '6.1'

This commit is contained in:
Jonathan Xu 2017-08-23 15:28:19 +08:00
commit 3e42e2d0b5
12 changed files with 162 additions and 19 deletions

View File

@ -5100,4 +5100,39 @@ seafile_get_file_count_info_by_path (const char *repo_id,
return ret;
}
char *
seafile_get_trash_repo_owner (const char *repo_id, GError **error)
{
if (!repo_id) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Argument should not be null");
return NULL;
}
return seaf_get_trash_repo_owner (repo_id);
}
int
seafile_mkdir_with_parents (const char *repo_id, const char *parent_dir,
const char *new_dir_path, const char *user,
GError **error)
{
if (!repo_id || !parent_dir || !new_dir_path || !user) {
g_set_error (error, 0, SEAF_ERR_BAD_ARGS, "Argument should not be null");
return -1;
}
if (!is_uuid_valid (repo_id)) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid repo id");
return -1;
}
if (seaf_repo_manager_mkdir_with_parents (seaf->repo_mgr, repo_id,
parent_dir, new_dir_path,
user, error) < 0) {
return -1;
}
return 0;
}
#endif /* SEAFILE_SERVER */

View File

@ -730,6 +730,10 @@ int
seafile_post_dir (const char *repo_id, const char *parent_dir,
const char *new_dir_name, const char *user,
GError **error);
int
seafile_mkdir_with_parents (const char *repo_id, const char *parent_dir,
const char *new_dir_path, const char *user,
GError **error);
/**
* delete a file/directory from the repo on server.
@ -1038,4 +1042,7 @@ GObject *
seafile_get_file_count_info_by_path (const char *repo_id,
const char *path,
GError **error);
char *
seafile_get_trash_repo_owner (const char *repo_id, GError **error);
#endif

View File

@ -964,3 +964,12 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
@searpc_func("object", ["string", "string"])
def get_file_count_info_by_path(repo_id, path):
pass
@searpc_func("string", ["string"])
def get_trash_repo_owner(repo_id):
pass
@searpc_func("int", ["string", "string", "string", "string"])
def seafile_mkdir_with_parents (repo_id, parent_dir, relative_path, username):
pass
mkdir_with_parents = seafile_mkdir_with_parents

View File

@ -675,6 +675,12 @@ class SeafileAPI(object):
def get_file_count_info_by_path(self, repo_id, path):
return seafserv_threaded_rpc.get_file_count_info_by_path(repo_id, path)
def get_trash_repo_owner (self, repo_id):
return seafserv_threaded_rpc.get_trash_repo_owner(repo_id)
def mkdir_with_parents (self, repo_id, parent_dir, relative_path, username):
return seafserv_threaded_rpc.mkdir_with_parents(repo_id, parent_dir, relative_path, username)
seafile_api = SeafileAPI()
class CcnetAPI(object):

53
scripts/export-users.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/bash
SCRIPT=$(readlink -f "$0")
INSTALLPATH=$(dirname "${SCRIPT}")
TOPDIR=$(dirname "${INSTALLPATH}")
default_ccnet_conf_dir=${TOPDIR}/ccnet
central_config_dir=${TOPDIR}/conf
function check_python_executable() {
if [[ "$PYTHON" != "" && -x $PYTHON ]]; then
return 0
fi
if which python2.7 2>/dev/null 1>&2; then
PYTHON=python2.7
elif which python27 2>/dev/null 1>&2; then
PYTHON=python27
else
echo
echo "Can't find a python executable of version 2.7 or above in PATH"
echo "Install python 2.7+ before continue."
echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it"
echo
exit 1
fi
}
function read_seafile_data_dir () {
seafile_ini=${default_ccnet_conf_dir}/seafile.ini
if [[ ! -f ${seafile_ini} ]]; then
echo "${seafile_ini} not found. Now quit"
exit 1
fi
seafile_data_dir=$(cat "${seafile_ini}")
if [[ ! -d ${seafile_data_dir} ]]; then
echo "Your seafile server data directory \"${seafile_data_dir}\" is invalid or doesn't exits."
echo "Please check it first, or create this directory yourself."
echo ""
exit 1;
fi
}
check_python_executable;
read_seafile_data_dir;
export CCNET_CONF_DIR=${default_ccnet_conf_dir}
export SEAFILE_CONF_DIR=${seafile_data_dir}
export SEAFILE_CENTRAL_CONF_DIR=${central_config_dir}
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.6/site-packages:${INSTALLPATH}/seafile/lib64/python2.6/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.7/site-packages:${INSTALLPATH}/seafile/lib64/python2.7/site-packages:$PYTHONPATH
manage_py=${INSTALLPATH}/seahub/manage.py
exec "$PYTHON" "$manage_py" export_users

View File

@ -831,7 +831,7 @@ fast_forward_or_merge (const char *repo_id,
SeafCommit *base,
SeafCommit *new_commit)
{
#define MAX_RETRY_COUNT 3
#define MAX_RETRY_COUNT 10
SeafRepo *repo = NULL;
SeafCommit *current_head = NULL, *merged_commit = NULL;
@ -924,16 +924,17 @@ retry:
seaf_commit_unref (merged_commit);
merged_commit = NULL;
repo = seaf_repo_manager_get_repo (seaf->repo_mgr, repo_id);
if (!repo) {
seaf_warning ("Repo %s doesn't exist.\n", repo_id);
ret = -1;
goto out;
}
if (++retry_cnt <= MAX_RETRY_COUNT) {
/* Sleep random time between 100 and 1000 millisecs. */
usleep (g_random_int_range(1, 11) * 100 * 1000);
repo = seaf_repo_manager_get_repo (seaf->repo_mgr, repo_id);
if (!repo) {
seaf_warning ("Repo %s doesn't exist.\n", repo_id);
ret = -1;
goto out;
}
goto retry;
} else {
ret = -1;

View File

@ -3898,3 +3898,10 @@ seaf_repo_manager_update_repo_info (SeafRepoManager *mgr,
seaf_commit_unref (head);
}
char *
seaf_get_trash_repo_owner (const char *repo_id)
{
char *sql = "SELECT owner_id from RepoTrash WHERE repo_id = ?";
return seaf_db_statement_get_string(seaf->db, sql, 1, "string", repo_id);
}

View File

@ -825,4 +825,7 @@ seaf_repo_manager_update_repo_info (SeafRepoManager *mgr,
int
set_repo_commit_to_db (const char *repo_id, const char *repo_name, gint64 update_time,
int version, gboolean is_encrypted, const char *last_modifier);
char *
seaf_get_trash_repo_owner (const char *repo_id);
#endif

View File

@ -442,7 +442,7 @@ gen_new_commit (const char *repo_id,
char *new_commit_id,
GError **error)
{
#define MAX_RETRY_COUNT 3
#define MAX_RETRY_COUNT 10
SeafRepo *repo = NULL;
SeafCommit *new_commit = NULL, *current_head = NULL, *merged_commit = NULL;
@ -560,19 +560,23 @@ retry:
seaf_commit_unref (merged_commit);
merged_commit = NULL;
repo = seaf_repo_manager_get_repo (seaf->repo_mgr, repo_id);
if (!repo) {
seaf_warning ("Repo %s doesn't exist.\n", repo_id);
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, "Invalid repo");
ret = -1;
goto out;
}
if (++retry_cnt <= MAX_RETRY_COUNT) {
/* Sleep random time between 100 and 1000 millisecs. */
usleep (g_random_int_range(1, 11) * 100 * 1000);
repo = seaf_repo_manager_get_repo (seaf->repo_mgr, repo_id);
if (!repo) {
seaf_warning ("Repo %s doesn't exist.\n", repo_id);
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, "Invalid repo");
ret = -1;
goto out;
}
goto retry;
} else {
seaf_warning ("Too many retries for concurrent update on repo %s. Stop retrying.\n",
repo_id);
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, "Concurrent update");
ret = -1;
goto out;
}

View File

@ -233,6 +233,11 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
"seafile_post_dir",
searpc_signature_int__string_string_string_string());
searpc_server_register_function ("seafserv-threaded-rpcserver",
seafile_mkdir_with_parents,
"seafile_mkdir_with_parents",
searpc_signature_int__string_string_string_string());
searpc_server_register_function ("seafserv-threaded-rpcserver",
seafile_del_file,
"seafile_del_file",
@ -368,6 +373,11 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
"get_file_count_info_by_path",
searpc_signature_object__string_string());
searpc_server_register_function ("seafserv-threaded-rpcserver",
seafile_get_trash_repo_owner,
"get_trash_repo_owner",
searpc_signature_string__string());
/* share repo to user */
searpc_server_register_function ("seafserv-threaded-rpcserver",
seafile_add_share,

View File

@ -6,6 +6,7 @@
#include "seafile-session.h"
#include "size-sched.h"
#define DEBUG_FLAG SEAFILE_DEBUG_OTHER
#include "log.h"
typedef struct SizeSchedulerPriv {
@ -169,8 +170,8 @@ set_repo_size (SeafDB *db,
}
} else {
if (strcmp (old_head_id, cached_head_id) != 0) {
g_message ("[size sched] Size update conflict for repo %s, rollback.\n",
repo_id);
seaf_debug ("[size sched] Size update conflict for repo %s, rollback.\n",
repo_id);
ret = SET_SIZE_CONFLICT;
goto rollback;
}

View File

@ -9,3 +9,10 @@ PORT = 10002
[Client]
PORT = 9999
[Database]
ENGINE = mysql
HOST = 127.0.0.1
USER = seafile
PASSWD = seafile
DB = ccnet_db