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
This commit is contained in:
Matthias Mair 2023-05-01 15:26:23 +02:00 committed by GitHub
parent c5ba632463
commit 08c4aa4998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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