Use same directory for OS.File.moveAtomic() temp file
Using the main temp directory was causing writes to fail when storage was on another filesystem.
This commit is contained in:
parent
32bebeb1cd
commit
383eac4657
|
@ -381,13 +381,7 @@ Zotero.File = new function(){
|
||||||
path,
|
path,
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
// Note: this will fail on Windows if the temp
|
tmpPath: path + ".tmp",
|
||||||
// directory is on a different drive from
|
|
||||||
// destination path
|
|
||||||
tmpPath: OS.Path.join(
|
|
||||||
Zotero.getTempDirectory().path,
|
|
||||||
OS.Path.basename(path) + ".tmp"
|
|
||||||
),
|
|
||||||
encoding: charset ? charset.toLowerCase() : 'utf-8'
|
encoding: charset ? charset.toLowerCase() : 'utf-8'
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
|
@ -82,6 +82,20 @@ describe("Zotero.File", function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#putContentsAsync()", function () {
|
||||||
|
it("should save via .tmp file", function* () {
|
||||||
|
var tmpDir = yield getTempDirectory();
|
||||||
|
var destFile = OS.Path.join(tmpDir, 'test.txt')
|
||||||
|
var tmpFile = destFile + ".tmp";
|
||||||
|
yield Zotero.File.putContentsAsync(tmpFile, 'A');
|
||||||
|
assert.isTrue(yield OS.File.exists(tmpFile));
|
||||||
|
yield Zotero.File.putContentsAsync(destFile, 'B');
|
||||||
|
assert.isFalse(yield OS.File.exists(tmpFile));
|
||||||
|
// Make sure .tmp file created when creating temp file was deleted too
|
||||||
|
assert.isFalse(yield OS.File.exists(tmpFile + '.tmp'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#copyDirectory()", function () {
|
describe("#copyDirectory()", function () {
|
||||||
it("should copy all files within a directory", function* () {
|
it("should copy all files within a directory", function* () {
|
||||||
var tmpDir = Zotero.getTempDirectory().path;
|
var tmpDir = Zotero.getTempDirectory().path;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user