diff --git a/database/migrations/20230911113331_alter_table.sql b/database/migrations/20230911113331_alter_table.sql deleted file mode 100644 index 3685db2..0000000 --- a/database/migrations/20230911113331_alter_table.sql +++ /dev/null @@ -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 \ No newline at end of file diff --git a/database/migrations/20230911113332_alter_table.sql b/database/migrations/20230911113332_alter_table.sql new file mode 100644 index 0000000..09a087e --- /dev/null +++ b/database/migrations/20230911113332_alter_table.sql @@ -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'); diff --git a/services/file.service.go b/services/file.service.go index 33cd75d..3a41c06 100644 --- a/services/file.service.go +++ b/services/file.service.go @@ -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) diff --git a/ui/teldrive-ui b/ui/teldrive-ui index 06f9a8b..a801ba0 160000 --- a/ui/teldrive-ui +++ b/ui/teldrive-ui @@ -1 +1 @@ -Subproject commit 06f9a8b4cac51b199d8fab8be781461d51d8b876 +Subproject commit a801ba0cbb6dc1d381594c6bfd190a69f52830c7