Skip to content

Commit

Permalink
text to VARCHAR(32767)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkywalkerSpace committed Feb 20, 2025
1 parent 2172cdf commit 3e6431a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 63 deletions.
22 changes: 11 additions & 11 deletions seahub/utils/ccnet_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def list_org_departments(self, org_id):
SELECT
g.group_id, group_name, creator_name, timestamp, type, parent_group_id
FROM
`{self.db_name}`.OrgGroup o
{self.db_name}.OrgGroup o
LEFT JOIN
`{self.db_name}`."Group" g
{self.db_name}.Group g
ON o.group_id=g.group_id
WHERE
org_id={org_id} AND parent_group_id<>0;
Expand Down Expand Up @@ -93,9 +93,9 @@ def search(q):
count_sql = f"""
SELECT count(1)
FROM
`{self.db_name}`.EmailUser t1
{self.db_name}.EmailUser t1
LEFT JOIN
`{self.db_name}`.UserRole t2
{self.db_name}.UserRole t2
ON
t1.email = t2.email
WHERE
Expand All @@ -106,9 +106,9 @@ def search(q):
sql = f"""
SELECT t1.id, t1.email, t1.is_staff, t1.is_active, t1.ctime, t2.role, t1.passwd
FROM
`{self.db_name}`.EmailUser t1
{self.db_name}.EmailUser t1
LEFT JOIN
`{self.db_name}`.UserRole t2
{self.db_name}.UserRole t2
ON
t1.email = t2.email
WHERE
Expand Down Expand Up @@ -152,7 +152,7 @@ def get_group_ids_admins_map(self, group_ids):
sql = f"""
SELECT user_name, group_id
FROM
`{self.db_name}`.GroupUser
{self.db_name}.GroupUser
WHERE
group_id IN ({group_ids_str}) AND is_staff = 1
"""
Expand All @@ -168,15 +168,15 @@ def get_group_ids_admins_map(self, group_ids):

def change_groups_into_departments(self, group_id):
sql = f"""
UPDATE `{self.db_name}`.Group g
UPDATE {self.db_name}.Group g
SET
g.creator_name = 'system admin',
g.parent_group_id = -1
WHERE
g.group_id = {group_id}
"""
structure_sql = f"""
INSERT INTO `{self.db_name}`.GroupStructure (group_id, path)
INSERT INTO {self.db_name}.GroupStructure (group_id, path)
VALUES ('{group_id}', '{group_id}')
"""

Expand All @@ -191,7 +191,7 @@ def get_active_users_by_user_list(self, user_list):
active_users = []
sql = f"""
SELECT email
FROM `{self.db_name}`.EmailUser
FROM {self.db_name}.EmailUser
WHERE
email IN ({user_list_str}) AND is_active = 1 AND email NOT LIKE '%%@seafile_group'
"""
Expand All @@ -204,7 +204,7 @@ def get_active_users_by_user_list(self, user_list):

def get_org_user_count(self, org_id):
sql = f"""
SELECT COUNT(1) FROM `{self.db_name}`.OrgUser WHERE org_id={org_id}
SELECT COUNT(1) FROM {self.db_name}.OrgUser WHERE org_id={org_id}
"""
user_count = 0
with connection.cursor() as cursor:
Expand Down
23 changes: 1 addition & 22 deletions seahub/utils/db_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,7 @@ def __init__(self):
self.db_name = self._get_seafile_db_name()

def _get_seafile_db_name(self):

conf_dir = os.environ.get('SEAFILE_CENTRAL_CONF_DIR') or \
os.environ.get('SEAFILE_CONF_DIR')

if not conf_dir:
return ""

config = configparser.ConfigParser()
seafile_conf_path = os.path.join(conf_dir, 'seafile.conf')
config.read(seafile_conf_path)

if not config.has_section('database'):
return ''

if 'sqlite' in config.get('database', 'type'):
return ''

db_name = config.get('database', 'user')
if not db_name:
raise Exception("Database name not configured.")

return db_name
return os.environ.get('SEAFILE_MYSQL_DB_SEAFILE_DB_NAME', '') or 'SYSDBA'

def get_repo_user_share_list(self, repo_id, org_id=''):

Expand Down
Loading

0 comments on commit 3e6431a

Please sign in to comment.