From 86acc244ebfd736df004d0b4228b0cbb90d5af3d Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 29 May 2024 01:57:58 +0200 Subject: [PATCH] Misc: Ignore error that file exists when creating it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 50a1757d17e94bfe787d1f3aced2572fa26ae43a to appease ESLint, so let’s add more specific `catch` body instead. --- tiling-assistant@leleat-on-github/extension.js | 12 +++++++++--- .../src/prefs/layoutsPrefs.js | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tiling-assistant@leleat-on-github/extension.js b/tiling-assistant@leleat-on-github/extension.js index 7a33abde..2cd642c4 100644 --- a/tiling-assistant@leleat-on-github/extension.js +++ b/tiling-assistant@leleat-on-github/extension.js @@ -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) { + throw e; + } } const path = GLib.build_filenamev([parentPath, '/tiledSessionRestore.json']); @@ -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) { + throw e; + } } file.replace_contents(JSON.stringify(saveObj), null, false, @@ -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) { + throw e; + } } const [success, contents] = file.load_contents(null); diff --git a/tiling-assistant@leleat-on-github/src/prefs/layoutsPrefs.js b/tiling-assistant@leleat-on-github/src/prefs/layoutsPrefs.js index 295c51d7..83e52d5c 100644 --- a/tiling-assistant@leleat-on-github/src/prefs/layoutsPrefs.js +++ b/tiling-assistant@leleat-on-github/src/prefs/layoutsPrefs.js @@ -169,7 +169,9 @@ export default class { try { parentDir.make_directory_with_parents(null); } catch (e) { - logError(e); + if (e.code !== Gio.IOErrorEnum.EXISTS) { + throw e; + } } // Create file, if it doesn't exist. @@ -180,7 +182,9 @@ export default class { try { file.create(Gio.FileCreateFlags.NONE, null); } catch (e) { - logError(e); + if (e.code !== Gio.IOErrorEnum.EXISTS) { + throw e; + } } return file;