From 8459015017fde8833a4159b8d56a32f92ebf4186 Mon Sep 17 00:00:00 2001 From: Arturo Albacete Date: Sat, 20 Jan 2024 21:19:53 +0100 Subject: skip if headers haven't changed --- modules/ui_common.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules/ui_common.py') diff --git a/modules/ui_common.py b/modules/ui_common.py index 92b00719..2c67834c 100644 --- a/modules/ui_common.py +++ b/modules/ui_common.py @@ -1,3 +1,4 @@ +import csv import dataclasses import json import html @@ -37,8 +38,6 @@ def plaintext_to_html(text, classname=None): def update_logfile(logfile_path, fields): - import csv - with open(logfile_path, "r", encoding="utf8", newline="") as file: reader = csv.reader(file) rows = list(reader) @@ -47,6 +46,10 @@ def update_logfile(logfile_path, fields): if not rows: return + # file is already synced, do nothing + if len(rows[0]) == len(fields): + return + rows[0] = fields # append new fields to each row as empty values @@ -60,7 +63,6 @@ def update_logfile(logfile_path, fields): def save_files(js_data, images, do_make_zip, index): - import csv filenames = [] fullfns = [] parsed_infotexts = [] -- cgit v1.2.1