Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions lib/shared/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,19 @@ export class ConfigManager extends GObject.Object {
} else {
const profileCustomSettingDir = Gio.File.new_for_path(path);
if (!profileCustomSettingDir.query_exists(null)) {
if (profileCustomSettingDir.make_directory_with_parents(null)) {
const createdStream = customSettingFile.create(Gio.FileCreateFlags.NONE, null);
const defaultContents = this.loadFileContents(defaultFile);
Logger.trace(defaultContents);
profileCustomSettingDir.make_directory_with_parents(null);
}
try {
const createdStream = customSettingFile.create(Gio.FileCreateFlags.NONE, null);
const defaultContents = this.loadFileContents(defaultFile);
Logger.trace(defaultContents);
if (defaultContents) {
createdStream.write_all(defaultContents, null);
}
createdStream.close(null);
return customSettingFile;
} catch (e) {
Logger.error(`Failed to create custom setting file: ${e}`);
}
}

Expand All @@ -137,7 +144,16 @@ export class ConfigManager extends GObject.Object {
if (success) {
const windowConfigContents = imports.byteArray.toString(contents);
Logger.trace(`${windowConfigContents}`);
windowProps = JSON.parse(windowConfigContents);
try {
if (windowConfigContents && windowConfigContents.trim().length > 0) {
windowProps = JSON.parse(windowConfigContents);
} else {
windowProps = this.loadDefaultWindowConfigContents();
}
} catch (err) {
Logger.error(`Failed to parse windowProps: ${err}`);
windowProps = this.loadDefaultWindowConfigContents();
}
}
return windowProps;
}
Expand Down