[Pkg-mozext-commits] [adblock-plus] 76/98: Issue 5157 - Update dependency on adblockpluscore to revision 66bcf4dca35a
David Prévot
taffit at moszumanska.debian.org
Tue Oct 24 01:30:23 UTC 2017
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 1a594264ceb2fe840ecd16126f9c059d87c3a4b6
Author: Wladimir Palant <trev at adblockplus.org>
Date: Tue Apr 11 17:13:15 2017 +0200
Issue 5157 - Update dependency on adblockpluscore to revision 66bcf4dca35a
---
dependencies | 2 +-
lib/io.js | 202 +++++++++++++++++++++++++++++++++++++--------------------
lib/prefs.json | 1 -
lib/utils.js | 7 --
4 files changed, 131 insertions(+), 81 deletions(-)
diff --git a/dependencies b/dependencies
index 26f486c..d57ba5b 100644
--- a/dependencies
+++ b/dependencies
@@ -1,5 +1,5 @@
_root = hg:https://hg.adblockplus.org/ git:https://github.com/adblockplus/
_self = buildtools/ensure_dependencies.py
buildtools = buildtools hg:daa9df1ee39f git:3ab934a
-adblockpluscore = adblockpluscore hg:387cff1ab5e0 git:634d770
+adblockpluscore = adblockpluscore hg:66bcf4dca35a git:8518e34
adblockplusui = adblockplusui hg:8ceaabb9c639 git:6222fd2
diff --git a/lib/io.js b/lib/io.js
index e566264..6ce3a63 100644
--- a/lib/io.js
+++ b/lib/io.js
@@ -55,120 +55,178 @@ function callWebExt(method, ...args)
});
}
-function attachCallback(promise, callback, fallback)
+function callLegacy(method, ...args)
{
- promise.then(result =>
+ return new Promise((resolve, reject) =>
{
- callback(null, result);
- }).catch(error =>
- {
- if (fallback && error == "NoSuchFile")
- fallback();
- else
- callback(error);
+ LegacyIO[method](...args, (error, result) =>
+ {
+ if (error)
+ reject(error);
+ else
+ resolve(result);
+ });
});
}
+function legacyFile(fileName)
+{
+ let file = LegacyIO.resolveFilePath("adblockplus");
+ file.append(fileName);
+ return file;
+}
+
exports.IO =
{
- resolveFilePath: LegacyIO.resolveFilePath,
+ /**
+ * @callback TextSink
+ * @param {string} line
+ */
/**
- * Reads strings from a file asynchronously, calls listener.process() with
- * each line read and with a null parameter once the read operation is done.
- * The callback will be called when the operation is done.
+ * Reads text lines from a file.
+ * @param {string} fileName
+ * Name of the file to be read
+ * @param {TextSink} listener
+ * Function that will be called for each line in the file
+ * @return {Promise}
+ * Promise to be resolved or rejected once the operation is completed
*/
- readFromFile(/**nsIFile*/ file, /**Object*/ listener, /**Function*/ callback)
+ readFromFile(fileName, listener)
{
- attachCallback(
- callWebExt("readFromFile", file.leafName).then(contents =>
+ return callWebExt("readFromFile", fileName).then(contents =>
+ {
+ return new Promise((resolve, reject) =>
{
- return new Promise((resolve, reject) =>
- {
- let lineIndex = 0;
+ let lineIndex = 0;
- function processBatch()
+ function processBatch()
+ {
+ while (lineIndex < contents.length)
{
- while (lineIndex < contents.length)
+ listener(contents[lineIndex++]);
+ if (lineIndex % 1000 == 0)
{
- listener.process(contents[lineIndex++]);
- if (lineIndex % 1000 == 0)
- {
- Utils.runAsync(processBatch);
- return;
- }
+ Utils.runAsync(processBatch);
+ return;
}
-
- listener.process(null);
- resolve();
}
+ resolve();
+ }
- processBatch();
- });
- }),
- callback,
- () => LegacyIO.readFromFile(file, listener, callback)
- );
+ processBatch();
+ });
+ }).catch(error =>
+ {
+ if (error == "NoSuchFile")
+ {
+ let wrapper = {
+ process(line)
+ {
+ if (line !== null)
+ listener(line);
+ }
+ };
+ return callLegacy("readFromFile", legacyFile(fileName), wrapper);
+ }
+ throw error;
+ });
},
/**
- * Writes string data to a file in UTF-8 format asynchronously. The callback
- * will be called when the write operation is done.
+ * Writes text lines to a file.
+ * @param {string} fileName
+ * Name of the file to be written
+ * @param {Iterable.<string>} data
+ * An array-like or iterable object containing the lines (without line
+ * endings)
+ * @return {Promise}
+ * Promise to be resolved or rejected once the operation is completed
*/
- writeToFile(/**nsIFile*/ file, /**Iterator*/ data, /**Function*/ callback)
+ writeToFile(fileName, data)
{
- attachCallback(
- callWebExt("writeToFile", file.leafName, Array.from(data)),
- callback
- );
+ return callWebExt("writeToFile", fileName, Array.from(data));
},
/**
- * Copies a file asynchronously. The callback will be called when the copy
- * operation is done.
+ * Copies a file.
+ * @param {string} fromFile
+ * Name of the file to be copied
+ * @param {string} toFile
+ * Name of the file to be written, will be overwritten if exists
+ * @return {Promise}
+ * Promise to be resolved or rejected once the operation is completed
*/
- copyFile(/**nsIFile*/ fromFile, /**nsIFile*/ toFile, /**Function*/ callback)
+ copyFile(fromFile, toFile)
{
- attachCallback(
- callWebExt("copyFile", fromFile.leafName, toFile.leafName),
- callback,
- () => LegacyIO.copyFile(fromFile, toFile, callback)
- );
+ return callWebExt("copyFile", fromFile, toFile).catch(error =>
+ {
+ if (error == "NoSuchFile")
+ return callLegacy("copyFile", legacyFile(fromFile), legacyFile(toFile));
+ throw error;
+ });
},
/**
- * Renames a file within the same directory, will call callback when done.
+ * Renames a file.
+ * @param {string} fromFile
+ * Name of the file to be renamed
+ * @param {string} newName
+ * New file name, will be overwritten if exists
+ * @return {Promise}
+ * Promise to be resolved or rejected once the operation is completed
*/
- renameFile(/**nsIFile*/ fromFile, /**String*/ newName, /**Function*/ callback)
+ renameFile(fromFile, newName)
{
- attachCallback(
- callWebExt("renameFile", fromFile.leafName, newName),
- callback,
- () => LegacyIO.renameFile(fromFile, newName, callback)
- );
+ return callWebExt("renameFile", fromFile, newName).catch(error =>
+ {
+ if (error == "NoSuchFile")
+ return callLegacy("renameFile", legacyFile(fromFile), newName);
+ throw error;
+ });
},
/**
- * Removes a file, will call callback when done.
+ * Removes a file.
+ * @param {string} fileName
+ * Name of the file to be removed
+ * @return {Promise}
+ * Promise to be resolved or rejected once the operation is completed
*/
- removeFile(/**nsIFile*/ file, /**Function*/ callback)
+ removeFile(fileName)
{
- attachCallback(
- callWebExt("removeFile", file.leafName),
- callback,
- () => LegacyIO.removeFile(file, callback)
- );
+ return callWebExt("removeFile", fileName).catch(error =>
+ {
+ if (error == "NoSuchFile")
+ return callLegacy("removeFile", legacyFile(fileName));
+ throw error;
+ });
},
/**
- * Gets file information such as whether the file exists.
+ * @typedef StatData
+ * @type {object}
+ * @property {boolean} exists
+ * true if the file exists
+ * @property {number} lastModified
+ * file modification time in milliseconds
*/
- statFile(/**nsIFile*/ file, /**Function*/ callback)
+
+ /**
+ * Retrieves file metadata.
+ * @param {string} fileName
+ * Name of the file to be looked up
+ * @return {Promise.<StatData>}
+ * Promise to be resolved with file metadata once the operation is
+ * completed
+ */
+ statFile(fileName)
{
- attachCallback(
- callWebExt("statFile", file.leafName),
- callback,
- () => LegacyIO.statFile(file, callback)
- );
+ return callWebExt("statFile", fileName).catch(error =>
+ {
+ if (error == "NoSuchFile")
+ return callLegacy("statFile", legacyFile(fileName));
+ throw error;
+ });
}
};
diff --git a/lib/prefs.json b/lib/prefs.json
index 4cdd539..445546b 100644
--- a/lib/prefs.json
+++ b/lib/prefs.json
@@ -14,7 +14,6 @@
"enable_key": "",
"flash_scrolltoitem": true,
"previewimages": true,
- "data_directory": "adblockplus",
"patternsbackups": 5,
"patternsbackupinterval": 24,
"whitelistschemes": "about chrome file irc moz-extension moz-safe-about news resource snews x-jsd addbook cid imap mailbox nntp pop data javascript moz-icon",
diff --git a/lib/utils.js b/lib/utils.js
index 6df64b4..032471e 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -326,13 +326,6 @@ let Utils = exports.Utils =
},
/**
- * DEPRECATED, do not use!
- */
- yield: function()
- {
- },
-
- /**
* Saves sidebar state before detaching/reattaching
*/
setParams: function(params)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list