[libhttpseverywhere] updater: ruleset path and error handling updated
- From: Daniel Brendle <elbren src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhttpseverywhere] updater: ruleset path and error handling updated
- Date: Wed, 24 Jan 2018 18:41:50 +0000 (UTC)
commit f45b0dceb0526c477d6b78a8f4a657beb218ef5a
Author: grindhold <grindhold gmx net>
Date: Wed Jan 24 19:38:41 2018 +0100
updater: ruleset path and error handling updated
corrected the path for the default rulesets file inside the archive
additionally provide a new error that gets thrown when the appropriate
file has not been found inside the downloaded archive
src/update.vala | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/update.vala b/src/update.vala
index bb8a9db..9168e28 100644
--- a/src/update.vala
+++ b/src/update.vala
@@ -44,6 +44,7 @@ namespace HTTPSEverywhere {
CANT_REACH_SERVER,
CANT_READ_HTTP_BODY,
CANT_READ_FROM_ARCHIVE,
+ NO_RULESET_FILE,
WRITE_FAILED
}
@@ -58,6 +59,7 @@ namespace HTTPSEverywhere {
private static string UPDATE_DIR = Path.build_filename(Environment.get_user_data_dir(),
"libhttpseverywhere");
private const string UPDATE_URL = "https://www.eff.org/files/https-everywhere-latest.xpi";
+ private const string RULESET_PATH = "rules/default.rulesets";
private const string LOCK_NAME = "lock";
private const string ETAG_NAME = "etag";
@@ -190,8 +192,10 @@ namespace HTTPSEverywhere {
string json = "";
unowned Archive.Entry e = null;
+ bool found_ruleset_file = false;
while (zipreader.next_header(out e) == Archive.Result.OK) {
- if (e != null && e.pathname() == "webextension/rules/default.rulesets") {
+ if (e != null && e.pathname() == Updater.RULESET_PATH) {
+ found_ruleset_file = true;
uint8[] jsonblock = new uint8[1024*1024];
while (true) {
var r = zipreader.read_data(jsonblock, 1024*1024);
@@ -211,6 +215,10 @@ namespace HTTPSEverywhere {
zipreader.read_data_skip();
}
+ // Throw an Exception when the expected ruleset file could not be found
+ if (!found_ruleset_file)
+ throw new UpdateError.NO_RULESET_FILE("Could not find expected ruleset file in the
downloaded archive: %s", Updater.RULESET_PATH);
+
// Copying the new Rules-File to the target
update_state = UpdateState.COPYING_RULES;
string rulesets_path = Path.build_filename(UPDATE_DIR, rulesets_file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]