You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2024/04/01 05:57:49 UTC
(incubator-streampark) 01/01: [Improve] project src path improvements
This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch project_src
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
commit 36b2d6f1a2625bdb97f25464de637ed92a635cf8
Author: benjobs <be...@gmail.com>
AuthorDate: Mon Apr 1 13:53:45 2024 +0800
[Improve] project src path improvements
---
.../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