From ccdc33424eac1126d69c8a41e3c27ff64c29b07c Mon Sep 17 00:00:00 2001 From: garvey-wong Date: Fri, 10 Jun 2022 12:00:44 +0800 Subject: [PATCH] feat: assign variable isDebug --- .../java/org/bdware/server/action/FileActions.java | 12 ++++++++---- .../org/bdware/server/action/MasterWSAction.java | 3 +++ .../org/bdware/server/action/TemporyTestAction.java | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/bdware/server/action/FileActions.java b/src/main/java/org/bdware/server/action/FileActions.java index 8e809e0..2d4b321 100644 --- a/src/main/java/org/bdware/server/action/FileActions.java +++ b/src/main/java/org/bdware/server/action/FileActions.java @@ -310,7 +310,10 @@ public class FileActions { } fileMap.remove(target.getAbsolutePath()); updateTime.remove(target.getAbsolutePath()); - String doi = unzipIfYpk(target, dir); + boolean isDebug = + transformedParam.containsKey("isDebug") + && Boolean.parseBoolean(transformedParam.get("isDebug")); + String doi = unzipIfYpk(target, dir, isDebug); if (null != doi) { retStr = retStr.replaceFirst("null", doi); } @@ -334,7 +337,7 @@ public class FileActions { return sb.toString(); } - private static String unzipIfYpk(File target, File dir) { + private static String unzipIfYpk(File target, File dir, boolean isDebug) { // [FileAction] unzipIfYpk, // target:/data/bdwaas/bdcontract/./BDWareProjectDir/private/045eeda3a001faad9d636ab1e973599ea87338a9576756eb10ceeca6083c1f76aac5cd201eab21c41342eb8aac40e9b283f0b6eae019644cdcc0a9f9aeb73de8fc/ContractUNknown.ypk targetDir:/data/bdwaas/bdcontract/./BDWareProjectDir/private/045eeda3a001faad9d636ab1e973599ea87338a9576756eb10ceeca6083c1f76aac5cd201eab21c41342eb8aac40e9b283f0b6eae019644cdcc0a9f9aeb73de8fc/ContractUNknown LOGGER.info( @@ -364,7 +367,7 @@ public class FileActions { + targetDir.getAbsolutePath()); YJSPacker.unpack(target.getAbsolutePath(), targetDir.getAbsolutePath()); final File tempDir = targetDir; - ContractManager.threadPool.execute(() -> startIfManifestDetected(tempDir)); + ContractManager.threadPool.execute(() -> startIfManifestDetected(tempDir, isDebug)); target.delete(); // 注册DOI并更新Manifest @@ -399,7 +402,7 @@ public class FileActions { return null; } - public static void startIfManifestDetected(File targetDir) { + public static void startIfManifestDetected(File targetDir, boolean isDebug) { try { String contractName = targetDir.getName(); String owner = targetDir.getParentFile().getName(); @@ -416,6 +419,7 @@ public class FileActions { targetDir.getParentFile().getAbsolutePath(), contractName); c.setScript(ypkPath); c.setOwner(owner); + c.setDebug(isDebug); CMActions.manager.startContractAndRedirect(c, System.out); // createPS() } } catch (Exception e) { diff --git a/src/main/java/org/bdware/server/action/MasterWSAction.java b/src/main/java/org/bdware/server/action/MasterWSAction.java index c2fc075..b5a936c 100644 --- a/src/main/java/org/bdware/server/action/MasterWSAction.java +++ b/src/main/java/org/bdware/server/action/MasterWSAction.java @@ -241,6 +241,9 @@ public class MasterWSAction { if (args.has("isPrivate")) { request.put("isPrivate", args.get("isPrivate").getAsString()); } + if (args.has("isDebug")) { + contract.setDebug(args.get("isDebug").getAsBoolean()); + } request.put("pubKey", managerAction.getPubKey()); request.put("action", "startContractTrustfully"); request.put("requestID", requestID); diff --git a/src/main/java/org/bdware/server/action/TemporyTestAction.java b/src/main/java/org/bdware/server/action/TemporyTestAction.java index 4781fb9..3952116 100644 --- a/src/main/java/org/bdware/server/action/TemporyTestAction.java +++ b/src/main/java/org/bdware/server/action/TemporyTestAction.java @@ -37,7 +37,7 @@ public class TemporyTestAction { @Action public void startContractForTest(JsonObject args, ResultCallback resultCallback) { FileActions.startIfManifestDetected( - new File(args.get("path").getAsString()).getAbsoluteFile()); + new File(args.get("path").getAsString()).getAbsoluteFile(), true); resultCallback.onResult("done"); }