mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-23 23:20:42 -04:00
install monero bins to local app directories and exclude from backup
This commit is contained in:
parent
748f698314
commit
8cdd65e7dd
5 changed files with 27 additions and 12 deletions
|
@ -24,6 +24,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
@ -38,13 +39,14 @@ public class ZipUtils {
|
|||
* @param dir The directory to create the zip from.
|
||||
* @param out The stream to write to.
|
||||
*/
|
||||
public static void zipDirToStream(File dir, OutputStream out, int bufferSize) throws Exception {
|
||||
public static void zipDirToStream(File dir, OutputStream out, int bufferSize, Collection<File> excludedFiles) throws Exception {
|
||||
|
||||
// Get all files in directory and subdirectories.
|
||||
ArrayList<String> fileList = new ArrayList<>();
|
||||
getFilesRecursive(dir, fileList);
|
||||
List<File> fileList = new ArrayList<>();
|
||||
getFilesRecursive(dir, fileList, excludedFiles);
|
||||
try (ZipOutputStream zos = new ZipOutputStream(out)) {
|
||||
for (String filePath : fileList) {
|
||||
for (File file : fileList) {
|
||||
String filePath = file.getAbsolutePath();
|
||||
log.info("Compressing: " + filePath);
|
||||
|
||||
// Creates a zip entry.
|
||||
|
@ -73,14 +75,15 @@ public class ZipUtils {
|
|||
/**
|
||||
* Get files list from the directory recursive to the subdirectory.
|
||||
*/
|
||||
public static void getFilesRecursive(File directory, List<String> fileList) {
|
||||
public static void getFilesRecursive(File directory, List<File> fileList, Collection<File> excludedFiles) {
|
||||
File[] files = directory.listFiles();
|
||||
if (files != null && files.length > 0) {
|
||||
for (File file : files) {
|
||||
if (excludedFiles != null && excludedFiles.contains(file)) continue;
|
||||
if (file.isFile()) {
|
||||
fileList.add(file.getAbsolutePath());
|
||||
fileList.add(file);
|
||||
} else {
|
||||
getFilesRecursive(file, fileList);
|
||||
getFilesRecursive(file, fileList, excludedFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue