This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev-2.1.4
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev-2.1.4 by this push:
new 2197ad296 [Improve] project src path improvements (#3649)
2197ad296 is described below
commit 2197ad29657cdbfdb9535fd7a4c6ad8572884409
Author: benjobs <[email protected]>
AuthorDate: Mon Apr 1 16:38:15 2024 +0800
[Improve] project src path improvements (#3649)
Co-authored-by: benjobs <[email protected]>
---
.../streampark/console/core/entity/Project.java | 35 ++++++++++++++--------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
index 396f85a6e..ecf69601e 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
@@ -106,27 +106,38 @@ public class Project implements Serializable {
private transient String dateTo;
- /** project source */
- private transient String appSource;
-
/** get project source */
@JsonIgnore
public File getAppSource() {
- if (appSource == null) {
- appSource = Workspace.PROJECT_LOCAL_PATH();
- }
- File sourcePath = new File(appSource);
+ File sourcePath = new File(Workspace.PROJECT_LOCAL_PATH());
if (!sourcePath.exists()) {
sourcePath.mkdirs();
+ } else if (sourcePath.isFile()) {
+ throw new IllegalArgumentException(
+ "[StreamPark] project source base path: "
+ + sourcePath.getAbsolutePath()
+ + " must be directory");
}
- if (sourcePath.isFile()) {
- throw new IllegalArgumentException("[StreamPark] sourcePath must be
directory");
+
+ String sourceDir = getSourceDirName();
+ File srcFile =
+ new File(String.format("%s/%s/%s", sourcePath.getAbsolutePath(), name,
sourceDir));
+ String newPath = String.format("%s/%s", sourcePath.getAbsolutePath(), id);
+ if (srcFile.exists()) {
+ File newFile = new File(newPath);
+ if (!newFile.exists()) {
+ newFile.mkdirs();
+ }
+ // old project path move to new path
+ srcFile.getParentFile().renameTo(newFile);
}
+ return new File(newPath, sourceDir);
+ }
+
+ private String getSourceDirName() {
String branches = this.getBranches() == null ? "main" : this.getBranches();
String rootName = url.replaceAll(".*/|\\.git|\\.svn", "");
- String fullName = rootName.concat("-").concat(branches);
- String path = String.format("%s/%s/%s", sourcePath.getAbsolutePath(),
getName(), fullName);
- return new File(path);
+ return rootName.concat("-").concat(branches);
}
@JsonIgnore