Skip to content

Commit

Permalink
#31030 Removing unnecessary file copy.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcolina committed Jan 14, 2025
1 parent a3b434b commit 907e713
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,7 @@ public class ImportStarterUtil {
* Fully configurable path for the backup directory.
*/
private static final String BACKUP_DIRECTORY = ConfigUtils.getBackupPath();
/*
* Unique identifier for the replica. This is used to create a unique directory for the replica.
* If the HOSTNAME environment variable is set, it will be used. Otherwise, a random UUID will be used.
* */
private static final String REPLICA_ID = System.getenv().getOrDefault("HOSTNAME", UUID.randomUUID().toString());

private String backupTempFilePath = BACKUP_DIRECTORY + File.separator + REPLICA_ID + File.separator + "temp";
private String backupTempFilePath = BACKUP_DIRECTORY + File.separator + "temp";
private ArrayList<String> classesWithIdentity = new ArrayList<>();
private Map<String, String> sequences;
private Map<String, String> tableIDColumns;
Expand Down Expand Up @@ -957,7 +951,7 @@ public boolean validateZipFile() {
String tempDirPath = getBackupTempFilePath();

if (starterZip == null || !starterZip.exists()) {
throw new DotStateException("Starter.zip does not exist:" + starterZip);
throw new DotStateException("Starter.zip does not exist: " + starterZip);
}

try {
Expand All @@ -975,18 +969,16 @@ public boolean validateZipFile() {
}
}

Path tempZipPath = tempDir.resolve(starterZip.getName());

// Copy the starter zip to the temp directory
Files.copy(starterZip.toPath(), tempZipPath, StandardCopyOption.REPLACE_EXISTING);

// Unzip the file if it is a valid zip
// Extract the zip file contents into the temp directory
if (starterZip.getName().toLowerCase().endsWith(".zip")) {
try (ZipFile zipFile = new ZipFile(starterZip)) {
ZipUtil.extract(zipFile, tempDir.toFile());
}
}

// Process the extracted contents (if needed)
Logger.info(this, String.format("Successfully processed starter.zip in: %s", tempDir));

return true;
} catch (IOException e) {
throw new DotStateException("Error processing starter.zip: " + e.getMessage(), e);
Expand Down

0 comments on commit 907e713

Please sign in to comment.