Browse Source

prohibit enable and disable function when segment is not completed (#1954)

Co-authored-by: jyong <jyong@dify.ai>
Co-authored-by: Joel <iamjoel007@gmail.com>
tags/0.4.4
Jyong 1 year ago
parent
commit
4d99c689f0
No account linked to committer's email address

+ 3
- 0
api/controllers/console/datasets/datasets_segments.py View File

@@ -156,6 +156,9 @@ class DatasetDocumentSegmentApi(Resource):
if not segment:
raise NotFound('Segment not found.')

if segment.status != 'completed':
raise NotFound('Segment is not completed, enable or disable function is not allowed')

document_indexing_cache_key = 'document_{}_indexing'.format(segment.document_id)
cache_result = redis_client.get(document_indexing_cache_key)
if cache_result is not None:

+ 1
- 1
api/tasks/disable_segment_from_index_task.py View File

@@ -27,7 +27,7 @@ def disable_segment_from_index_task(segment_id: str):
raise NotFound('Segment not found')

if segment.status != 'completed':
return
raise NotFound('Segment is not completed , disable action is not allowed.')

indexing_cache_key = 'segment_{}_indexing'.format(segment.id)


+ 1
- 1
api/tasks/enable_segment_to_index_task.py View File

@@ -29,7 +29,7 @@ def enable_segment_to_index_task(segment_id: str):
raise NotFound('Segment not found')

if segment.status != 'completed':
return
raise NotFound('Segment is not completed, enable action is not allowed.')

indexing_cache_key = 'segment_{}_indexing'.format(segment.id)


+ 1
- 1
web/app/components/datasets/documents/detail/completed/SegmentCard.tsx View File

@@ -128,7 +128,7 @@ const SegmentCard: FC<ISegmentCardProps> = ({
>
<Switch
size='md'
disabled={archived}
disabled={archived || detail.status !== 'completed'}
defaultValue={enabled}
onChange={async (val) => {
await onChangeSwitch?.(id, val)

Loading…
Cancel
Save