Use OS.File for file reads in Zotero.File.get(Binary)ContentsAsync()
This is the recommended approach (since NetUtil can still do some main-thread I/O for files) and avoids warnings in the console. For getContentsAsync(), also sends nsIURIs and string URIs to Zotero.HTTP.request(), which should be used instead. This makes getBinaryContentsAsync() much slower (due to the conversion from an array of bytes to a binary string), but it's only used in tests. For one test that compares two large files, use MD5 instead.
This commit is contained in:
parent
12da3f00dc
commit
d857a06661
3 changed files with 130 additions and 91 deletions
|
@ -109,10 +109,12 @@ describe("Zotero.Fulltext", function () {
|
|||
yield Zotero.Fulltext.downloadPDFTool('info', pdfToolsVersion);
|
||||
|
||||
assert.ok(Zotero.Fulltext.pdfInfoIsRegistered());
|
||||
|
||||
assert.equal(
|
||||
(yield Zotero.File.getBinaryContentsAsync(cacheExecPath)),
|
||||
(yield Zotero.File.getBinaryContentsAsync(execPath))
|
||||
(yield Zotero.Utilities.Internal.md5Async(cacheExecPath, false)),
|
||||
(yield Zotero.Utilities.Internal.md5Async(execPath, false))
|
||||
);
|
||||
|
||||
if (!Zotero.isWin) {
|
||||
assert.equal((yield OS.File.stat(execPath)).unixMode, 0o755);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue