mirror of
https://github.com/KohakuBlueleaf/KohakuHub.git
synced 2026-04-30 09:28:35 -05:00
fix db impl to match current approach
This commit is contained in:
@@ -7,6 +7,7 @@ import hashlib
|
|||||||
import struct
|
import struct
|
||||||
import zlib
|
import zlib
|
||||||
|
|
||||||
|
|
||||||
def compute_git_object_sha1(obj_type: str, content: bytes) -> str:
|
def compute_git_object_sha1(obj_type: str, content: bytes) -> str:
|
||||||
"""Compute Git object SHA-1.
|
"""Compute Git object SHA-1.
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from typing import Optional
|
|||||||
|
|
||||||
from fastapi.responses import Response
|
from fastapi.responses import Response
|
||||||
|
|
||||||
|
|
||||||
class HFErrorCode:
|
class HFErrorCode:
|
||||||
"""HuggingFace error codes for X-Error-Code header.
|
"""HuggingFace error codes for X-Error-Code header.
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from fastapi import HTTPException
|
|||||||
|
|
||||||
from kohakuhub.db import Organization, Repository, User, UserOrganization
|
from kohakuhub.db import Organization, Repository, User, UserOrganization
|
||||||
|
|
||||||
|
|
||||||
def check_namespace_permission(
|
def check_namespace_permission(
|
||||||
namespace: str, user: User, require_admin: bool = False
|
namespace: str, user: User, require_admin: bool = False
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import secrets
|
|||||||
|
|
||||||
import bcrypt
|
import bcrypt
|
||||||
|
|
||||||
|
|
||||||
def hash_password(password: str) -> str:
|
def hash_password(password: str) -> str:
|
||||||
"""Hash password with bcrypt."""
|
"""Hash password with bcrypt."""
|
||||||
return bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode()
|
return bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode()
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from kohakuhub.db import (
|
|||||||
db,
|
db,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# User operations
|
# User operations
|
||||||
def get_user_by_id(user_id: int) -> User | None:
|
def get_user_by_id(user_id: int) -> User | None:
|
||||||
"""Get user by ID."""
|
"""Get user by ID."""
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from datetime import datetime
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
class Color:
|
class Color:
|
||||||
"""ANSI color codes for terminal output."""
|
"""ANSI color codes for terminal output."""
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
from kohakuhub.config import cfg
|
from kohakuhub.config import cfg
|
||||||
from kohakuhub.lakefs_rest_client import LakeFSRestClient, get_lakefs_rest_client
|
from kohakuhub.lakefs_rest_client import LakeFSRestClient, get_lakefs_rest_client
|
||||||
|
|
||||||
|
|
||||||
def get_lakefs_client() -> LakeFSRestClient:
|
def get_lakefs_client() -> LakeFSRestClient:
|
||||||
"""Get configured LakeFS REST client.
|
"""Get configured LakeFS REST client.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user