1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Replace SSHUploader file filter

- The file names in FILES_NOT_TO_COPY are full names and not partial names, so the check should not check if a file name contains such a name, but rather whether a file name fully matches such a name.
- Replaced the FILES_NOT_TO_COPY by a HashSet since this provides O(1) lookups, rather than O(n) lookups where n is the size of the set.
This commit is contained in:
Pieter12345 2019-03-21 20:39:08 +01:00 committed by Cristian Maglie
parent 61bbc382b5
commit 91c262dc0e

View File

@ -49,13 +49,17 @@ import processing.app.helpers.StringUtils;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static processing.app.I18n.tr;
public class SSHUploader extends Uploader {
private static final List<String> FILES_NOT_TO_COPY = Arrays.asList(".DS_Store", ".Trash", "Thumbs.db", "__MACOSX");
private static final Set<String> FILES_NOT_TO_COPY =
Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(".DS_Store", ".Trash", "Thumbs.db", "__MACOSX")));
private final BoardPort port;
@ -223,7 +227,7 @@ public class SSHUploader extends Uploader {
}
for (File file : files) {
if (!StringUtils.stringContainsOneOf(file.getName(), FILES_NOT_TO_COPY)) {
if (!FILES_NOT_TO_COPY.contains(file.getName())) {
if (file.isDirectory() && file.canExecute()) {
scp.startFolder(file.getName());
recursiveSCP(file, scp);