mirror of https://github.com/apache/nifi.git
NIFI-1261: Use consistent file separators for ListFile / TestListFile based on what the Operating System uses
This commit is contained in:
parent
f83e6d33c5
commit
bfe6fad502
|
@ -222,10 +222,10 @@ public class ListFile extends AbstractListProcessor<FileInfo> {
|
||||||
|
|
||||||
final Path relativePath = directoryPath.toAbsolutePath().relativize(filePath.getParent());
|
final Path relativePath = directoryPath.toAbsolutePath().relativize(filePath.getParent());
|
||||||
String relativePathString = relativePath.toString();
|
String relativePathString = relativePath.toString();
|
||||||
relativePathString = relativePathString.isEmpty() ? "./" : relativePathString + "/";
|
relativePathString = relativePathString.isEmpty() ? "." + File.separator : relativePathString + File.separator;
|
||||||
|
|
||||||
final Path absPath = filePath.toAbsolutePath();
|
final Path absPath = filePath.toAbsolutePath();
|
||||||
final String absPathString = absPath.getParent().toString() + "/";
|
final String absPathString = absPath.getParent().toString() + File.separator;
|
||||||
|
|
||||||
attributes.put(CoreAttributes.PATH.key(), relativePathString);
|
attributes.put(CoreAttributes.PATH.key(), relativePathString);
|
||||||
attributes.put(CoreAttributes.FILENAME.key(), fileInfo.getFileName());
|
attributes.put(CoreAttributes.FILENAME.key(), fileInfo.getFileName());
|
||||||
|
|
|
@ -430,16 +430,16 @@ public class TestListFile {
|
||||||
|
|
||||||
switch (filename) {
|
switch (filename) {
|
||||||
case "file1.txt":
|
case "file1.txt":
|
||||||
assertEquals("./", path);
|
assertEquals("." + File.separator, path);
|
||||||
mff.assertAttributeEquals(CoreAttributes.ABSOLUTE_PATH.key(), file1.getParentFile().getAbsolutePath() + "/");
|
mff.assertAttributeEquals(CoreAttributes.ABSOLUTE_PATH.key(), file1.getParentFile().getAbsolutePath() + File.separator);
|
||||||
break;
|
break;
|
||||||
case "file2.txt":
|
case "file2.txt":
|
||||||
assertEquals("subdir1/", path);
|
assertEquals("subdir1" + File.separator, path);
|
||||||
mff.assertAttributeEquals(CoreAttributes.ABSOLUTE_PATH.key(), file2.getParentFile().getAbsolutePath() + "/");
|
mff.assertAttributeEquals(CoreAttributes.ABSOLUTE_PATH.key(), file2.getParentFile().getAbsolutePath() + File.separator);
|
||||||
break;
|
break;
|
||||||
case "file3.txt":
|
case "file3.txt":
|
||||||
assertEquals("subdir1/subdir2/", path);
|
assertEquals("subdir1" + File.separator + "subdir2" + File.separator, path);
|
||||||
mff.assertAttributeEquals(CoreAttributes.ABSOLUTE_PATH.key(), file3.getParentFile().getAbsolutePath() + "/");
|
mff.assertAttributeEquals(CoreAttributes.ABSOLUTE_PATH.key(), file3.getParentFile().getAbsolutePath() + File.separator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,9 +511,9 @@ public class TestListFile {
|
||||||
final Path directoryPath = new File(TESTDIR).toPath();
|
final Path directoryPath = new File(TESTDIR).toPath();
|
||||||
final Path relativePath = directoryPath.relativize(file1.toPath().getParent());
|
final Path relativePath = directoryPath.relativize(file1.toPath().getParent());
|
||||||
String relativePathString = relativePath.toString();
|
String relativePathString = relativePath.toString();
|
||||||
relativePathString = relativePathString.isEmpty() ? "./" : relativePathString + "/";
|
relativePathString = relativePathString.isEmpty() ? "." + File.separator : relativePathString + File.separator;
|
||||||
final Path absolutePath = file1.toPath().toAbsolutePath();
|
final Path absolutePath = file1.toPath().toAbsolutePath();
|
||||||
final String absolutePathString = absolutePath.getParent().toString() + "/";
|
final String absolutePathString = absolutePath.getParent().toString() + File.separator;
|
||||||
final FileStore store = Files.getFileStore(file1Path);
|
final FileStore store = Files.getFileStore(file1Path);
|
||||||
final DateFormat formatter = new SimpleDateFormat(ListFile.FILE_MODIFY_DATE_ATTR_FORMAT, Locale.US);
|
final DateFormat formatter = new SimpleDateFormat(ListFile.FILE_MODIFY_DATE_ATTR_FORMAT, Locale.US);
|
||||||
final String time3Formatted = formatter.format(time3rounded);
|
final String time3Formatted = formatter.format(time3rounded);
|
||||||
|
|
Loading…
Reference in New Issue