diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index cc17a2927c..9fe1133b66 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -1010,14 +1010,17 @@ Zotero.File = new function(){ } - this.createDirectoryIfMissingAsync = async function (path) { + this.createDirectoryIfMissingAsync = async function (path, options = {}) { try { await OS.File.makeDir( path, - { - ignoreExisting: false, - unixMode: 0o755 - } + Object.assign( + { + ignoreExisting: false, + unixMode: 0o755 + }, + options + ) ) } catch (e) { diff --git a/test/tests/fileTest.js b/test/tests/fileTest.js index 04f3c8bce9..23df1953fb 100644 --- a/test/tests/fileTest.js +++ b/test/tests/fileTest.js @@ -293,6 +293,13 @@ describe("Zotero.File", function () { assert.ok(e); assert.match(e.message, /^Broken symlink/); }); + + it("should handle 'from' in options", async function () { + var tmpPath = await getTempDirectory(); + var path = OS.Path.join(tmpPath, 'a', 'b'); + await Zotero.File.createDirectoryIfMissingAsync(path, { from: tmpPath }); + assert.isTrue(await OS.File.exists(path)); + }); }); describe("#zipDirectory()", function () {