save encrypt state in uploads

This commit is contained in:
divyam234 2023-12-08 03:35:40 +05:30
parent 3e30b8797c
commit 205cb0bc4d
5 changed files with 6 additions and 0 deletions

View file

@ -1,4 +1,5 @@
-- +goose Up -- +goose Up
-- +goose StatementBegin -- +goose StatementBegin
ALTER TABLE teldrive.files ADD COLUMN "encrypted" BOOLEAN NOT NULL DEFAULT FALSE; ALTER TABLE teldrive.files ADD COLUMN "encrypted" BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE teldrive.uploads ADD COLUMN "encrypted" BOOLEAN NOT NULL DEFAULT FALSE;
-- +goose StatementEnd -- +goose StatementEnd

View file

@ -46,6 +46,7 @@ func ToUploadOut(in *models.Upload) *schemas.UploadPartOut {
ChannelID: in.ChannelID, ChannelID: in.ChannelID,
PartNo: in.PartNo, PartNo: in.PartNo,
Size: in.Size, Size: in.Size,
Encrypted: in.Encrypted,
} }
return out return out
} }

View file

@ -10,6 +10,7 @@ type Upload struct {
Name string `gorm:"type:text"` Name string `gorm:"type:text"`
PartNo int `gorm:"type:integer"` PartNo int `gorm:"type:integer"`
PartId int `gorm:"type:integer"` PartId int `gorm:"type:integer"`
Encrypted bool `gorm:"default:false"`
ChannelID int64 `gorm:"type:bigint"` ChannelID int64 `gorm:"type:bigint"`
Size int64 `gorm:"type:bigint"` Size int64 `gorm:"type:bigint"`
CreatedAt time.Time `gorm:"default:timezone('utc'::text, now())"` CreatedAt time.Time `gorm:"default:timezone('utc'::text, now())"`

View file

@ -13,6 +13,7 @@ type UploadPartOut struct {
PartNo int `json:"partNo"` PartNo int `json:"partNo"`
ChannelID int64 `json:"channelId"` ChannelID int64 `json:"channelId"`
Size int64 `json:"size"` Size int64 `json:"size"`
Encrypted bool `json:"encrypted"`
} }
type UploadOut struct { type UploadOut struct {
@ -26,4 +27,5 @@ type UploadPart struct {
PartNo int `json:"partNo"` PartNo int `json:"partNo"`
ChannelID int64 `json:"channelId"` ChannelID int64 `json:"channelId"`
Size int64 `json:"size"` Size int64 `json:"size"`
Encrypted bool `json:"encrypted"`
} }

View file

@ -201,6 +201,7 @@ func (us *UploadService) UploadFile(c *gin.Context) (*schemas.UploadPartOut, *ty
Size: fileSize, Size: fileSize,
PartNo: uploadQuery.PartNo, PartNo: uploadQuery.PartNo,
UserId: userId, UserId: userId,
Encrypted: uploadQuery.Encrypted,
} }
if err := us.Db.Create(partUpload).Error; err != nil { if err := us.Db.Create(partUpload).Error; err != nil {