Skip to content

Commit 91c262d

Browse files
Pieter12345cmaglie
authored andcommitted
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.
1 parent 61bbc38 commit 91c262d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arduino-core/src/cc/arduino/packages/uploaders/SSHUploader.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@
4949
import java.io.File;
5050
import java.io.IOException;
5151
import java.util.Arrays;
52+
import java.util.Collections;
53+
import java.util.HashSet;
5254
import java.util.List;
55+
import java.util.Set;
5356

5457
import static processing.app.I18n.tr;
5558

5659
public class SSHUploader extends Uploader {
5760

58-
private static final List<String> FILES_NOT_TO_COPY = Arrays.asList(".DS_Store", ".Trash", "Thumbs.db", "__MACOSX");
61+
private static final Set<String> FILES_NOT_TO_COPY =
62+
Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(".DS_Store", ".Trash", "Thumbs.db", "__MACOSX")));
5963

6064
private final BoardPort port;
6165

@@ -223,7 +227,7 @@ private void recursiveSCP(File from, SCP scp) throws IOException {
223227
}
224228

225229
for (File file : files) {
226-
if (!StringUtils.stringContainsOneOf(file.getName(), FILES_NOT_TO_COPY)) {
230+
if (!FILES_NOT_TO_COPY.contains(file.getName())) {
227231
if (file.isDirectory() && file.canExecute()) {
228232
scp.startFolder(file.getName());
229233
recursiveSCP(file, scp);

0 commit comments

Comments
 (0)