mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-02-24 15:05:41 +08:00
remove session column from user table
This commit is contained in:
parent
9e7bdd6256
commit
6db6f62dfb
3 changed files with 10 additions and 10 deletions
|
@ -84,7 +84,9 @@ BEGIN
|
|||
END;
|
||||
$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION teldrive.move_directory(src text, dest text,user_id bigint) RETURNS VOID AS $$
|
||||
drop function if exists teldrive.move_directory;
|
||||
|
||||
CREATE OR REPLACE FUNCTION teldrive.move_directory(src text, dest text,u_id bigint) RETURNS VOID AS $$
|
||||
DECLARE
|
||||
src_parent TEXT;
|
||||
src_base TEXT;
|
||||
|
@ -94,11 +96,11 @@ DECLARE
|
|||
src_id text;
|
||||
BEGIN
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM teldrive.files WHERE path = src) THEN
|
||||
IF NOT EXISTS (SELECT 1 FROM teldrive.files WHERE path = src and user_id = u_id) THEN
|
||||
RAISE EXCEPTION 'source directory not found';
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT 1 FROM teldrive.files WHERE path = dest) THEN
|
||||
IF EXISTS (SELECT 1 FROM teldrive.files WHERE path = dest and user_id = u_id) THEN
|
||||
RAISE EXCEPTION 'destination directory exists';
|
||||
END IF;
|
||||
|
||||
|
@ -107,17 +109,17 @@ BEGIN
|
|||
SELECT parent, base INTO dest_parent, dest_base FROM teldrive.split_path(dest);
|
||||
|
||||
IF src_parent != dest_parent then
|
||||
select id into dest_id from teldrive.create_directories(user_id,dest);
|
||||
update teldrive.files set parent_id = dest_id where parent_id = (select id from teldrive.files where path = src) and id != dest_id;
|
||||
select id into dest_id from teldrive.create_directories(u_id,dest);
|
||||
update teldrive.files set parent_id = dest_id where parent_id = (select id from teldrive.files where path = src) and id != dest_id and user_id = u_id;
|
||||
|
||||
IF POSITION(CONCAT(src,'/') IN dest) = 0 then
|
||||
delete from teldrive.files where path = src;
|
||||
delete from teldrive.files where path = src and user_id = u_id;
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
IF src_base != dest_base and src_parent = dest_parent then
|
||||
select id into src_id from teldrive.files where path = src;
|
||||
select id into src_id from teldrive.files where path = src and user_id = u_id;
|
||||
perform from teldrive.update_folder(src_id,dest_base);
|
||||
END IF;
|
||||
|
|
@ -9,7 +9,6 @@ type User struct {
|
|||
Name string `gorm:"type:text"`
|
||||
UserName string `gorm:"type:text"`
|
||||
IsPremium bool `gorm:"type:bool"`
|
||||
TgSession string `gorm:"type:text"`
|
||||
UpdatedAt time.Time `gorm:"default:timezone('utc'::text, now())"`
|
||||
CreatedAt time.Time `gorm:"default:timezone('utc'::text, now())"`
|
||||
}
|
||||
|
|
|
@ -158,7 +158,6 @@ func (as *AuthService) LogIn(c *gin.Context) (*schemas.Message, *types.AppError)
|
|||
Name: session.Name,
|
||||
UserName: session.UserName,
|
||||
IsPremium: session.IsPremium,
|
||||
TgSession: session.Sesssion,
|
||||
}
|
||||
|
||||
var result []models.User
|
||||
|
@ -186,7 +185,7 @@ func (as *AuthService) LogIn(c *gin.Context) (*schemas.Message, *types.AppError)
|
|||
ParentID: "root",
|
||||
}
|
||||
if err := as.Db.Create(file).Error; err != nil {
|
||||
return nil, &types.AppError{Error: errors.New("failed to create or update user"),
|
||||
return nil, &types.AppError{Error: errors.New("failed to create root folder"),
|
||||
Code: http.StatusInternalServerError}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue