changes related to upload check

This commit is contained in:
divyam234 2023-09-11 13:32:32 +05:30
parent fb9985d6f0
commit 5f3552c8fe
4 changed files with 10 additions and 10 deletions

View file

@ -1,8 +0,0 @@
-- +goose Up
-- +goose StatementBegin
ALTER TABLE teldrive.files DROP CONSTRAINT unique_file;
ALTER TABLE teldrive.files ADD CONSTRAINT unique_file UNIQUE (name, parent_id, user_id,status)
-- +goose StatementEnd

View file

@ -0,0 +1,5 @@
-- +goose Up
ALTER TABLE teldrive.files DROP CONSTRAINT IF EXISTS unique_file;
CREATE UNIQUE INDEX unique_file ON teldrive.files (name, parent_id, user_id) WHERE (status= 'active');

View file

@ -195,7 +195,10 @@ func (fs *FileService) ListFiles(c *gin.Context) (*schemas.FileResponse, *types.
delete(filterQuery, "updated_at")
}
setOrderFilter(query, &pagingParams, &sortingParams)
if filterQuery["path"] != "" && filterQuery["name"] != "" {
query.Where("parent_id in (?)", fs.Db.Model(&models.File{}).Select("id").Where("path = ?", filterQuery["path"]))
delete(filterQuery, "path")
}
query.Order("type DESC").Order(getOrder(sortingParams)).Where(filterQuery)

@ -1 +1 @@
Subproject commit 06f9a8b4cac51b199d8fab8be781461d51d8b876
Subproject commit a801ba0cbb6dc1d381594c6bfd190a69f52830c7