feat: 录像存储server类型,可以设置如何存储了 (#4699)

feat: Server 类型的录像存储可以上传到 oss等上面
This commit is contained in:
老广
2020-09-27 14:34:47 +08:00
committed by GitHub
parent d4037998c8
commit e3648d11b1
8 changed files with 74 additions and 33 deletions

View File

@@ -2,43 +2,18 @@
#
import os
from django.core.cache import cache
from django.conf import settings
from django.core.files.storage import default_storage
import jms_storage
from assets.models import Asset, SystemUser
from users.models import User
from common.utils import get_logger
from .const import USERS_CACHE_KEY, ASSETS_CACHE_KEY, SYSTEM_USER_CACHE_KEY
from .backends import server_replay_storage
from .models import ReplayStorage
logger = get_logger(__name__)
def get_session_asset_list():
return Asset.objects.values_list('hostname', flat=True)
def get_session_user_list():
return User.objects.exclude(role=User.ROLE.APP).values_list('username', flat=True)
def get_session_system_user_list():
return SystemUser.objects.values_list('username', flat=True)
def get_user_list_from_cache():
return cache.get(USERS_CACHE_KEY)
def get_asset_list_from_cache():
return cache.get(ASSETS_CACHE_KEY)
def get_system_user_list_from_cache():
return cache.get(SYSTEM_USER_CACHE_KEY)
def find_session_replay_local(session):
# 新版本和老版本的文件后缀不同
session_path = session.get_rel_replay_path() # 存在外部存储上的路径
@@ -62,6 +37,8 @@ def download_session_replay(session):
for storage in replay_storages
if not storage.in_defaults()
}
if settings.SERVER_REPLAY_STORAGE:
configs['SERVER_REPLAY_STORAGE'] = settings.SERVER_REPLAY_STORAGE
if not configs:
msg = "Not found replay file, and not remote storage set"
return None, msg