@@ -801,21 +801,16 @@ private void buildNodejsImage(DeploymentContext context) {
801801 if (!TechTypeEnum .NODEJS .getCode ().equals (context .getApp ().getTechType ())) {
802802 return ;
803803 }
804- File branchFile = new File (context .getLocalPathOfBranch ());
805- File targetFile = new File (branchFile .getParent () + "/" + context .getApp ().getAppName ());
806- rename (branchFile , targetFile );
804+ File targetFile = new File (context .getLocalPathOfBranch ());
807805 doBuildImage (context , context .getApp ().getBaseImage (), null , Arrays .asList (targetFile .toPath ()));
808806 }
809807
810808 private void buildNuxtImage (DeploymentContext context ) {
811809 if (!TechTypeEnum .NUXT .getCode ().equals (context .getApp ().getTechType ())) {
812810 return ;
813811 }
814-
815812 AppExtendNuxt appExted = context .getApp ().getAppExtend ();
816- File branchFile = new File (context .getLocalPathOfBranch ());
817- File targetFile = new File (branchFile .getParent () + "/" + context .getApp ().getAppName ());
818- rename (branchFile , targetFile );
813+ File targetFile = new File (context .getLocalPathOfBranch ());
819814 String baseImage = Constants .NODE_IMAGE_BASE_URL + appExted .getNodeVersion ().substring (1 );
820815 doBuildImage (context , baseImage , null , Arrays .asList (targetFile .toPath ()));
821816 }
@@ -824,9 +819,7 @@ private void buildHtmlImage(DeploymentContext context) {
824819 if (!TechTypeEnum .HTML .getCode ().equals (context .getApp ().getTechType ())) {
825820 return ;
826821 }
827- File branchFile = new File (context .getLocalPathOfBranch ());
828- File targetFile = new File (branchFile .getParent () + "/" + context .getApp ().getAppName ());
829- rename (branchFile , targetFile );
822+ File targetFile = new File (context .getLocalPathOfBranch ());
830823 doBuildImage (context , context .getApp ().getBaseImage (), null , Arrays .asList (targetFile .toPath ()));
831824 }
832825
@@ -868,34 +861,12 @@ private void buildDjangoImage(DeploymentContext context) {
868861
869862 private void buildPythonImage (DeploymentContext context , List <String > entrypoint ) {
870863 App app = context .getApp ();
871- File branchFile = new File (context .getLocalPathOfBranch ());
872- File targetFile = new File (branchFile .getParent () + "/" + app .getAppName ());
873- rename (branchFile , targetFile );
864+ File targetFile = new File (context .getLocalPathOfBranch ());
874865 String version = ((AppExtendPython )app .getAppExtend ()).getPythonVersion ();
875866 String baseImage = Constants .PYTHON_IMAGE_BASE_URL + version .substring (1 );
876867 doBuildImage (context , baseImage , entrypoint , Arrays .asList (targetFile .toPath ()));
877868 }
878869
879- private boolean rename (File source , File target ) {
880- boolean success = false ;
881- //如果30秒还没成功,则报错
882- for (int i = 0 ; i < 300 ; i ++) {
883- if (source .renameTo (target )) {
884- success = true ;
885- break ;
886- }
887- try {
888- Thread .sleep (100 );
889- } catch (InterruptedException e ) {
890- //ignore
891- }
892- }
893- if (!success ) {
894- LogUtils .throwException (logger , MessageCodeEnum .RENAME_FILE_FAILURE );
895- }
896- return success ;
897- }
898-
899870 private void doBuildImage (DeploymentContext context , String baseImageName , List <String > entrypoint , List <Path > targetFiles ) {
900871 ImageRepo imageRepo = context .getGlobalConfigAgg ().getImageRepo ();
901872 String imageUrl = imageRepo .getUrl ();
0 commit comments