x.z is not considered derived from xy.z
@see https://www.filebot.net/forums/viewtopic.php?p=24206#p24206
This commit is contained in:
parent
4f1bd2c7f9
commit
be9fc83fcd
|
@ -323,13 +323,13 @@ public final class FileUtilities {
|
|||
}
|
||||
|
||||
public static boolean isDerived(File derivate, File prime) {
|
||||
return isDerived(getName(derivate), prime);
|
||||
}
|
||||
String n = getName(prime).toLowerCase();
|
||||
String s = getName(derivate).toLowerCase();
|
||||
|
||||
public static boolean isDerived(String derivate, File prime) {
|
||||
String base = getName(prime).trim().toLowerCase();
|
||||
derivate = derivate.trim().toLowerCase();
|
||||
return derivate.startsWith(base);
|
||||
if (s.startsWith(n)) {
|
||||
return s.length() == n.length() || !Character.isLetterOrDigit(s.charAt(n.length())); // e.g. x.z is not considered derived from xy.z
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isDerivedByExtension(File derivate, File prime) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
package net.filebot.util;
|
||||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class FileUtilitiesTest {
|
||||
|
||||
|
@ -15,7 +15,6 @@ public class FileUtilitiesTest {
|
|||
assertFalse(FileUtilities.hasExtension(".hidden", "txt"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getExtension() {
|
||||
assertEquals("txt", FileUtilities.getExtension("abc.txt"));
|
||||
|
@ -28,7 +27,6 @@ public class FileUtilitiesTest {
|
|||
assertEquals(null, FileUtilities.getExtension("archive.invalid extension"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getNameWithoutExtension() {
|
||||
assertEquals("abc", FileUtilities.getNameWithoutExtension("abc.txt"));
|
||||
|
@ -41,4 +39,13 @@ public class FileUtilitiesTest {
|
|||
assertEquals("archive.invalid extension", FileUtilities.getNameWithoutExtension("archive.invalid extension"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isDerived() {
|
||||
assertTrue(FileUtilities.isDerived(new File("avatar.eng.srt"), new File("avatar.mp4")));
|
||||
assertTrue(FileUtilities.isDerived(new File("1.z"), new File("1.xyz")));
|
||||
assertTrue(FileUtilities.isDerived(new File("1.xyz"), new File("1.z")));
|
||||
assertFalse(FileUtilities.isDerived(new File("1.eng.srt"), new File("10.mp4")));
|
||||
assertFalse(FileUtilities.isDerived(new File("10.z"), new File("1.mp4")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue