Skip to content

Commit

Permalink
Misc: Ignore error that file exists when creating it
Browse files Browse the repository at this point in the history
Those files existing is expected at all times after the initial creation.
As a result, journal continued being spammed with errors like:

    Gio.IOErrorEnum: Error creating directory ~/.config/tiling-assistant: File exists
    Gio.IOErrorEnum: Error opening file “~/.config/tiling-assistant/tiledSessionRestore.json”: File exists

The logging was only added in 50a1757 to appease ESLint,
so let’s add more specific `catch` body instead.
  • Loading branch information
Jan Tojnar committed May 29, 2024
1 parent 93f1edc commit 86acc24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 9 additions & 3 deletions tiling-assistant@leleat-on-github/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ export default class TilingAssistantExtension extends Extension {
try {
parent.make_directory_with_parents(null);
} catch (e) {
logError(e);
if (e.code !== Gio.IOErrorEnum.EXISTS) {

Check failure on line 308 in tiling-assistant@leleat-on-github/extension.js

View workflow job for this annotation

GitHub Actions / Run linters

Unnecessary { after 'if' condition
throw e;
}
}

const path = GLib.build_filenamev([parentPath, '/tiledSessionRestore.json']);
Expand All @@ -314,7 +316,9 @@ export default class TilingAssistantExtension extends Extension {
try {
file.create(Gio.FileCreateFlags.NONE, null);
} catch (e) {
logError(e);
if (e.code !== Gio.IOErrorEnum.EXISTS) {

Check failure on line 319 in tiling-assistant@leleat-on-github/extension.js

View workflow job for this annotation

GitHub Actions / Run linters

Unnecessary { after 'if' condition
throw e;
}
}

file.replace_contents(JSON.stringify(saveObj), null, false,
Expand All @@ -340,7 +344,9 @@ export default class TilingAssistantExtension extends Extension {
try {
file.create(Gio.FileCreateFlags.NONE, null);
} catch (e) {
logError(e);
if (e.code !== Gio.IOErrorEnum.EXISTS) {

Check failure on line 347 in tiling-assistant@leleat-on-github/extension.js

View workflow job for this annotation

GitHub Actions / Run linters

Unnecessary { after 'if' condition
throw e;
}
}

const [success, contents] = file.load_contents(null);
Expand Down
8 changes: 6 additions & 2 deletions tiling-assistant@leleat-on-github/src/prefs/layoutsPrefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ export default class {
try {
parentDir.make_directory_with_parents(null);
} catch (e) {
logError(e);
if (e.code !== Gio.IOErrorEnum.EXISTS) {

Check failure on line 172 in tiling-assistant@leleat-on-github/src/prefs/layoutsPrefs.js

View workflow job for this annotation

GitHub Actions / Run linters

Unnecessary { after 'if' condition
throw e;
}
}

// Create file, if it doesn't exist.
Expand All @@ -180,7 +182,9 @@ export default class {
try {
file.create(Gio.FileCreateFlags.NONE, null);
} catch (e) {
logError(e);
if (e.code !== Gio.IOErrorEnum.EXISTS) {

Check failure on line 185 in tiling-assistant@leleat-on-github/src/prefs/layoutsPrefs.js

View workflow job for this annotation

GitHub Actions / Run linters

Unnecessary { after 'if' condition
throw e;
}
}

return file;
Expand Down

0 comments on commit 86acc24

Please sign in to comment.