diff --git a/scripts/build.number b/scripts/build.number index efd8c14..9be5847 100644 --- a/scripts/build.number +++ b/scripts/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sun Aug 07 12:40:19 EDT 2022 -build.number=34 +#Sun Aug 07 13:46:38 EDT 2022 +build.number=42 diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java index 914a718..d6839f8 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java @@ -143,7 +143,7 @@ public class I2PFirefoxProfileBuilder { } File baseProfileDir = new File(baseProfile); File profileDir = new File(profile); - if (!baseProfileDir.exists() || !profileDir.exists()) { + if (!baseProfileDir.exists() || profileDir.listFiles() == null ) { return false; } try { @@ -152,8 +152,42 @@ public class I2PFirefoxProfileBuilder { System.out.println("Error copying base profile to profile"+e); return false; } + // if user.js does not exist yet, make an empty one. + if (!touch(profileDir.toString(), "user.js")) { + return false; + } + // if extensions does not exist yet, make an empty one. + if (!mkExtensionsDir(profileDir.toString())){ + return false; + } + + return copyStrictOptions(); } + private static boolean touch(String dir, String file){ + File f = new File(dir, file); + if (!f.exists()) { + try { + f.createNewFile(); + } catch (Exception e) { + System.out.println("Error creating "+file+" in "+dir+" "+e); + return false; + } + } + return true; + } + private static boolean mkExtensionsDir(String dir) { + File f = new File(dir, "extensions"); + if (!f.exists()) { + try { + f.mkdir(); + } catch (Exception e) { + System.out.println("Error creating extensions directory in "+dir+" "+e); + return false; + } + } + return true; + } /* * Copy the strict options from the base profile to the profile @@ -186,6 +220,10 @@ public class I2PFirefoxProfileBuilder { System.out.println("Error copying base profile to profile"+e); return false; } + // if user-overrides.js does not exist yet, make an empty one. + if (!touch(profileDir.toString(), "user-overrides.js")) { + return false; + } return true; } diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java index 0227b98..f875646 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java @@ -43,10 +43,6 @@ public class I2PFirefoxProfileChecker { System.out.println("user.js is not valid"); return false; } - if (!validateFile(profileDir+"/user-overrides.js")){ - System.out.println("user-overrides.js is not valid"); - return false; - } if (!validateExtensionDirectory(profileDir+"/extensions")){ System.out.println("extensions directory is invalid"); return false;