From 08c4aa499885ff932b3ed6389b3058b042cb547e Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Mon, 1 May 2023 15:26:23 +0200 Subject: [PATCH] Make sure plugins are always on a new line (#4721) * "Install Plugin" via GUI fails to add plugin to plugins.txt correctly for first plugin Fixes #4719 * remove old change as it was not the root issue * make sure plugins are always written on a new line --- InvenTree/plugin/serializers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/InvenTree/plugin/serializers.py b/InvenTree/plugin/serializers.py index 2f902e3d2a..64f1b0d908 100644 --- a/InvenTree/plugin/serializers.py +++ b/InvenTree/plugin/serializers.py @@ -154,7 +154,13 @@ class PluginConfigInstallSerializer(serializers.Serializer): # save plugin to plugin_file if installed successfull if success: + # Read content of plugin file + plg_lines = open(settings.PLUGIN_FILE).readlines() with open(settings.PLUGIN_FILE, "a") as plugin_file: + # Check if last line has a newline + if plg_lines[-1][-1:] != '\n': + plugin_file.write('\n') + # Write new plugin to file plugin_file.write(f'{" ".join(install_name)} # Installed {timezone.now()} by {str(self.context["request"].user)}\n') # Check for migrations