Throw clearer error when 'storage' is a broken symlink
Instead of '(NS_ERROR_FILE_ALREADY_EXISTS) [nsIFile.create]', throw "Broken symlink at <path>". Closes #1834
This commit is contained in:
parent
83cdbd8e5c
commit
8614e73aa8
2 changed files with 74 additions and 7 deletions
|
@ -239,6 +239,38 @@ describe("Zotero.File", function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe("#createDirectoryIfMissing()", function () {
|
||||
it("should throw error on broken symlink", async function () {
|
||||
if (Zotero.isWin) {
|
||||
this.skip();
|
||||
};
|
||||
|
||||
var tmpPath = await getTempDirectory();
|
||||
var destPath = OS.Path.join(tmpPath, 'missing');
|
||||
var linkPath = OS.Path.join(tmpPath, 'link');
|
||||
await OS.File.unixSymLink(destPath, linkPath);
|
||||
|
||||
assert.throws(() => Zotero.File.createDirectoryIfMissing(linkPath), /^Broken symlink/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#createDirectoryIfMissingAsync()", function () {
|
||||
it("should throw error on broken symlink", async function () {
|
||||
if (Zotero.isWin) {
|
||||
this.skip();
|
||||
};
|
||||
|
||||
var tmpPath = await getTempDirectory();
|
||||
var destPath = OS.Path.join(tmpPath, 'missing');
|
||||
var linkPath = OS.Path.join(tmpPath, 'link');
|
||||
await OS.File.unixSymLink(destPath, linkPath);
|
||||
|
||||
var e = await getPromiseError(Zotero.File.createDirectoryIfMissingAsync(linkPath));
|
||||
assert.ok(e);
|
||||
assert.match(e.message, /^Broken symlink/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#zipDirectory()", function () {
|
||||
it("should compress a directory recursively", function* () {
|
||||
var tmpPath = Zotero.getTempDirectory().path;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue