Fix 'false' filename after case-only rename on Macs
Zotero.File.move() now forces `overwrite` if the old and new filenames differ only by case, since otherwise on a case-insensitive filesystem OS.File.move() does an existence check and thinks that the target file exists.
This commit is contained in:
parent
595ba396ef
commit
81e2bee452
3 changed files with 35 additions and 2 deletions
|
@ -132,6 +132,17 @@ describe("Zotero.File", function () {
|
|||
assert.isTrue(await OS.File.exists(destFile));
|
||||
});
|
||||
|
||||
// Only relevant on a case-insensitive filesystem
|
||||
it("should rename a file with a case-only change (Mac)", async function () {
|
||||
var tmpDir = await getTempDirectory();
|
||||
var sourceFile = OS.Path.join(tmpDir, 'a');
|
||||
var destFile = OS.Path.join(tmpDir, 'A');
|
||||
await Zotero.File.putContentsAsync(sourceFile, 'foo');
|
||||
var newFilename = await Zotero.File.rename(sourceFile, 'A');
|
||||
assert.equal(newFilename, 'A');
|
||||
assert.equal(await Zotero.File.getContentsAsync(destFile), 'foo');
|
||||
});
|
||||
|
||||
it("should overwrite an existing file if `overwrite` is true", async function () {
|
||||
var tmpDir = await getTempDirectory();
|
||||
var sourceFile = OS.Path.join(tmpDir, 'a');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue