Delete temp files mode.

This commit is contained in:
zaxar163 2019-01-08 17:50:40 +04:00
parent a238f79fe6
commit 5ba69c155a
No known key found for this signature in database
GPG key ID: CEE900027AE098E0
3 changed files with 9 additions and 5 deletions

View file

@ -140,7 +140,8 @@ public static final class Config {
public boolean isWarningMissArchJava;
public boolean enabledProGuard;
public boolean stripLineNumbers;
public boolean deleteTempFiles;
public String startScript;
@ -576,9 +577,11 @@ private void generateConfigIfNotExists() throws IOException {
newConfig.whitelistRejectString = "Вас нет в белом списке";
newConfig.threadCoreCount = 0; // on your own
newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors();
newConfig.enabledProGuard = true;
newConfig.stripLineNumbers = false;
newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors();
newConfig.deleteTempFiles = false;
// Set server address
LogHelper.println("LaunchServer address: ");
newConfig.setAddress(commandHandler.readLine());

View file

@ -54,12 +54,13 @@ public void build() throws IOException {
long time_task_end = System.currentTimeMillis();
long time_task = time_task_end - time_this;
time_this = time_task_end;
if (isNeedDelete) Files.delete(oldPath);
if (isNeedDelete && server.config.deleteTempFiles) Files.delete(oldPath);
isNeedDelete = task.allowDelete();
LogHelper.subInfo("Task %s processed from %d millis",task.getName(), time_task);
}
long time_end = System.currentTimeMillis();
IOHelper.move(thisPath, syncBinaryFile);
if (isNeedDelete && server.config.deleteTempFiles) IOHelper.move(thisPath, syncBinaryFile);
else IOHelper.copy(thisPath, syncBinaryFile);
LogHelper.info("Build successful from %d millis",time_end - time_start);
}

View file

@ -51,7 +51,7 @@ private void attach(ZipOutputStream output) throws IOException {
ZipEntry e = input.getNextEntry();
while (e != null) {
String filename = e.getName();
if (exclusions.stream().noneMatch(exc -> filename.startsWith(exc))) {
if (exclusions.stream().noneMatch(filename::startsWith)) {
output.putNextEntry(IOHelper.newZipEntry(e));
IOHelper.transfer(input, output);
}