Verified Commit d7633d54 authored by Daniel Mangold's avatar Daniel Mangold
Browse files

Added config for excluding files from updates

parent 04f940c5
package h05;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
* This class contains constants that are used as settings for the tests.
* They will not be overwritten when an update is downloaded
* They will not be overwritten when an update is downloaded (assuming this file is in {@link Config#EXCLUDED_FILES})
*/
@SuppressWarnings("JavadocReference")
public class Config {
......@@ -28,6 +29,15 @@ public class Config {
*/
public static final boolean CHECK_FOR_UPDATES = true, CHECK_HASHES = true, AUTO_UPDATE = true;
/**
* A list of files (with path relative to project root) to be excluded from updates.
* It may be necessary to temporarily remove the configuration file from this list, e.g. when a update
* is downloaded that needs additional constants that are not yet included in this file.
*/
public static final List<String> EXCLUDED_FILES = List.of(
"src/test/java/h05/Config.java"
);
/**
* Determines which build variant should be used in MyTree.
* More specifically, what value to pass as the second parameter of the constructor.
......
......@@ -219,8 +219,12 @@ public class Utils {
(CHECK_HASHES || (AUTO_UPDATE && remoteVersion.compareTo(localVersion) > 0)) && line != null && line.length() != 0;
line = remoteReader.readLine()
) {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
String fileName = line.split(" +")[0], expectedHash = line.split(" +")[1];
if (EXCLUDED_FILES.contains(fileName))
continue;
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
File file = new File(fileName);
if (!file.exists()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment