-
Notifications
You must be signed in to change notification settings - Fork 40
fix: dataset deletion bugs #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ice/src/main/java/com/datamate/datamanagement/interfaces/dto/BatchDeleteFilesRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.datamate.datamanagement.interfaces.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotEmpty; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * 批量删除文件请求 | ||
| */ | ||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class BatchDeleteFilesRequest { | ||
|
|
||
| /** | ||
| * 要删除的文件ID列表 | ||
| */ | ||
| @NotEmpty(message = "文件ID列表不能为空") | ||
| private List<String> fileIds; | ||
|
|
||
| /** | ||
| * 文件路径前缀(用于处理子目录中的文件) | ||
| */ | ||
| private String prefix = ""; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ervice/src/main/java/com/datamate/datamanagement/interfaces/validation/ValidFilePath.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.datamate.datamanagement.interfaces.validation; | ||
|
|
||
| import jakarta.validation.Constraint; | ||
| import jakarta.validation.Payload; | ||
|
|
||
| import java.lang.annotation.*; | ||
|
|
||
| /** | ||
| * 文件路径校验注解 | ||
| * 验证文件路径不包含非法字符(允许 / 用于支持文件夹上传) | ||
| * | ||
| * @author DataMate | ||
| * @since 2026/03/12 | ||
| */ | ||
| @Documented | ||
| @Constraint(validatedBy = ValidFilePathValidator.class) | ||
| @Target({ElementType.FIELD, ElementType.PARAMETER}) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| public @interface ValidFilePath { | ||
|
|
||
| String message() default "文件路径包含非法字符"; | ||
|
|
||
| Class<?>[] groups() default {}; | ||
|
|
||
| Class<? extends Payload>[] payload() default {}; | ||
| } |
45 changes: 45 additions & 0 deletions
45
...c/main/java/com/datamate/datamanagement/interfaces/validation/ValidFilePathValidator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package com.datamate.datamanagement.interfaces.validation; | ||
|
|
||
| import com.datamate.datamanagement.infrastructure.exception.DataManagementErrorCode; | ||
| import jakarta.validation.ConstraintValidator; | ||
| import jakarta.validation.ConstraintValidatorContext; | ||
|
|
||
| import java.util.regex.Pattern; | ||
|
|
||
| /** | ||
| * 文件路径校验器 | ||
| * 允许路径分隔符 / 用于支持文件夹上传 | ||
| * | ||
| * @author DataMate | ||
| * @since 2026/03/12 | ||
| */ | ||
| public class ValidFilePathValidator implements ConstraintValidator<ValidFilePath, String> { | ||
|
|
||
| /** | ||
| * 文件路径正则表达式 | ||
| * 不允许包含特殊字符: \ : * ? " < > | \0 | ||
| * 允许字母、数字、中文、常见符号(- _ . space /) | ||
| * 注意:允许 / 是为了支持文件夹上传的相对路径 | ||
| */ | ||
| private static final Pattern FILE_PATH_PATTERN = Pattern.compile( | ||
| "^[^\\\\:*?\"<>|\\x00]+$" | ||
| ); | ||
|
|
||
| @Override | ||
| public boolean isValid(String value, ConstraintValidatorContext context) { | ||
| if (value == null || value.isEmpty()) { | ||
| return true; // 空值由 @NotBlank 等其他注解处理 | ||
| } | ||
|
|
||
| boolean isValid = FILE_PATH_PATTERN.matcher(value).matches(); | ||
|
|
||
| if (!isValid) { | ||
| context.disableDefaultConstraintViolation(); | ||
| context.buildConstraintViolationWithTemplate( | ||
| DataManagementErrorCode.FILE_NAME_INVALID.getMessage() | ||
| ).addConstraintViolation(); | ||
| } | ||
|
|
||
| return isValid; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.