Skip to content

Commit

Permalink
[JENKINS-49649] - Stop serializing FileSystemParameterDefinition#map …
Browse files Browse the repository at this point in the history
…to the disk
  • Loading branch information
oleg-nenashev committed Feb 21, 2018
1 parent a2764b3 commit 31c35d5
Showing 1 changed file with 18 additions and 20 deletions.
Expand Up @@ -117,8 +117,6 @@ private FormValidation checkRegex(String regex) {
private String regexExcludePattern;

private String value;

SortedMap<String, Long> map;



Expand Down Expand Up @@ -192,35 +190,35 @@ private String getEffectiveDefaultValue() throws IOException {


public List<String> getFsObjectsList() throws IOException {
map = new TreeMap<String, Long>();

TreeMap<String, Long> map = new TreeMap<>();
File rootDir = new File(path);
File[] listFiles = rootDir.listFiles();

if(listFiles!=null){
switch (getSelectedEnumType()) {
case SYMLINK:
createSymlinkMap(listFiles);
createSymlinkMap(listFiles, map);
break;
case DIRECTORY:
createDirectoryMap(listFiles);
createDirectoryMap(listFiles, map);
break;
case FILE:
createFileMap(listFiles);
createFileMap(listFiles, map);
break;
default:
createAllObjectsMap(listFiles);
createAllObjectsMap(listFiles, map);
break;
}
}


return sortList();
return sortList(map);
}



List<String> sortList() {
List<String> sortList(Map<String, Long> map) {
List<String> list;

if (map.isEmpty()) {
Expand All @@ -231,7 +229,7 @@ List<String> sortList() {
}else {
// Sorting:
if (isSortByLastModified()) {
list = createTimeSortedList();
list = createTimeSortedList(map);
}else {
list = new ArrayList<String>();
list.addAll(map.keySet());
Expand All @@ -247,7 +245,7 @@ List<String> sortList() {



List<String> createTimeSortedList() {
List<String> createTimeSortedList(Map<String, Long> map) {
List<String> list = new ArrayList<String>();

Collection<Long> valuesC = map.values();
Expand Down Expand Up @@ -304,33 +302,33 @@ private boolean isPatternMatching(String name) {
}


private void createSymlinkMap(File[] listFiles) throws IOException {
private void createSymlinkMap(File[] listFiles, Map<String, Long> target) throws IOException {

for (File file : listFiles) {
if (!file.isHidden() && isSymlink(file) && isPatternMatching(file.getName())) {
map.put(file.getName(),file.lastModified());
target.put(file.getName(),file.lastModified());
LOGGER.finest("add " + file);
}
}
}


private void createDirectoryMap(File[] listFiles) throws IOException {
private void createDirectoryMap(File[] listFiles, Map<String, Long> target) throws IOException {

for (File file : listFiles) {
if (!file.isHidden() && file.isDirectory() && !isSymlink(file) && isPatternMatching(file.getName())) {
map.put(file.getName(),file.lastModified());
target.put(file.getName(),file.lastModified());
LOGGER.finest("add " + file);
}
}
}


private void createFileMap(File[] listFiles) throws IOException {
private void createFileMap(File[] listFiles, Map<String, Long> target) throws IOException {

for (File file : listFiles) {
if (!file.isHidden() && file.isFile() && !isSymlink(file) && isPatternMatching(file.getName())) {
map.put(file.getName(),file.lastModified());
target.put(file.getName(),file.lastModified());
LOGGER.finest("add " + file);
}
}
Expand All @@ -340,11 +338,11 @@ private void createFileMap(File[] listFiles) throws IOException {



private void createAllObjectsMap(File[] listFiles) {
private void createAllObjectsMap(File[] listFiles, Map<String, Long> target) {

for (File file : listFiles) {
if (!file.isHidden() && isPatternMatching(file.getName())) {
map.put(file.getName(),file.lastModified());
target.put(file.getName(),file.lastModified());
LOGGER.finest("add " + file);
}
}
Expand Down

0 comments on commit 31c35d5

Please sign in to comment.