Update for group handle

pull/3/head
jinhai 2019-04-09 11:34:37 +08:00
parent 42039c22af
commit e5f782eda6
3 changed files with 14 additions and 19 deletions

View File

@ -1,24 +1,23 @@
from engine.model.group_table import GroupTable
from engine.model.file_table import FileTable
from engine.controller.error_code import ErrorCode
from engine import db
class MetaManager(object):
def Sync(self):
@staticmethod
def Sync():
db.session.commit()
def AddGroup(self, group_name, dimension):
group = GroupTable.query.filter(GroupTable.group_name==group_id).first()
if group:
return ErrorCode.ALREADY_EXIST, group_name
else:
new_group = GroupTable(group_name, dimension)
GroupHandler.CreateGroupDirectory(group_id)
@staticmethod
def AddGroup(group_name, dimension):
new_group = GroupTable(group_name, dimension)
# add into database
db.session.add(new_group)
self.Sync()
return ErrorCode.SUCCESS_CODE, group_name
# add into database
db.session.add(new_group)
db.session.commit()
return ErrorCode.SUCCESS_CODE, group_name
@staticmethod
def GetGroup(group_name):

View File

@ -3,7 +3,7 @@ from engine.settings import DATABASE_DIRECTORY
class StorageManager(object):
@staticmethod
def CreateGroup(group_name):
def AddGroup(group_name):
path = StorageManager.GetGroupDirectory(group_name)
path = path.strip()
path=path.rstrip("\\")

View File

@ -27,12 +27,8 @@ class VectorEngine(object):
if(error == ErrorCode.SUCCESS_CODE):
return ErrorCode.FAULT_CODE, group_name
else:
StorageManager.CreateGroup(group_name)
new_group = GroupTable(group_name, dimension)
# add into database
db.session.add(new_group)
db.session.commit()
StorageManager.AddGroup(group_name)
MetaManager.AddGroup(group_name, dimension)
return VectorEngine.SUCCESS_CODE, group_name