1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-01 08:53:31 +02:00

Create the info directory if it doesn't exist.

This fixes a bug in 1.1.
This commit is contained in:
Doug Kearns
2015-04-08 04:06:11 +10:00
parent e030d11bfd
commit df81b7fca2

View File

@@ -235,10 +235,8 @@ var Storage = Module("Storage", {
if (obj.store && storage.infoPath) { if (obj.store && storage.infoPath) {
var { path } = storage.infoPath.child(obj.name); var { path } = storage.infoPath.child(obj.name);
yield OS.File.makeDir(storage.infoPath.path, yield AsyncFile(storage.infoPath.path).mkdir();
{ ignoreExisting: true }); yield AsyncFile(path).write(obj.serial,
yield OS.File.writeAtomic(
path, obj.serial,
{ tmpPath: path + ".part" }); { tmpPath: path + ".part" });
} }
}), }),
@@ -251,7 +249,7 @@ var Storage = Module("Storage", {
}, },
infoPath: Class.Memoize(() => infoPath: Class.Memoize(() =>
File(IO.runtimePath.replace(/,.*/, "")) File(IO.runtimePath.split(",")[0])
.child("info").child(config.profileName)), .child("info").child(config.profileName)),
exists: function exists(key) this.infoPath.child(key).exists(), exists: function exists(key) this.infoPath.child(key).exists(),
@@ -838,13 +836,13 @@ var AsyncFile = Class("AsyncFile", File, {
* Creates a new directory, along with any parent directories which * Creates a new directory, along with any parent directories which
* do not currently exist. * do not currently exist.
* *
* @param {string} path The path of the directory to create.
* @param {object} options Options for directory creation. As in * @param {object} options Options for directory creation. As in
* `OS.File.makeDir` * `OS.File.makeDir`
* @returns {Promise} * @returns {Promise}
*/ */
mkdir: promises.task(function* mkdir(path, options) { // TODO: Is there a reason not to merge this with makeDir?
let split = OS.Path.split(path); mkdir: promises.task(function* mkdir(options) {
let split = OS.Path.split(this.path);
util.assert(split.absolute); util.assert(split.absolute);
let file = File(split.winDrive ? split.winDrive + File.PATH_SEP let file = File(split.winDrive ? split.winDrive + File.PATH_SEP
@@ -869,7 +867,7 @@ var AsyncFile = Class("AsyncFile", File, {
{ ignoreExisting: true, { ignoreExisting: true,
from: file.path }); from: file.path });
yield OS.File.makeDir(path, options); yield OS.File.makeDir(this.path, options);
}), }),
_setEncoding: function _setEncoding(options) { _setEncoding: function _setEncoding(options) {
@@ -903,7 +901,8 @@ var AsyncFile = Class("AsyncFile", File, {
* Writes the string *buf* to this file. * Writes the string *buf* to this file.
*/ */
write: function write(buf, options={}) { write: function write(buf, options={}) {
return OS.File.writeAtomic(this.path, this._setEncoding(options)); return OS.File.writeAtomic(this.path, buf,
this._setEncoding(options));
}, },
copyTo: function copyTo(path, options) { copyTo: function copyTo(path, options) {