mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-04-23 06:21:37 +00:00
Merged JSON files are now only updated on disk if the contents have actually changed.
This commit is contained in:
@@ -289,10 +289,16 @@ def incremental_merge(source_dir: str, target_dir: str, media_dir: str):
|
|||||||
else:
|
else:
|
||||||
target_chats[jid] = chat
|
target_chats[jid] = chat
|
||||||
|
|
||||||
# Write merged data back to the target file
|
# Serialize merged data
|
||||||
with open(target_path, 'w') as merged_file:
|
merged_data = {jid: chat.to_json() for jid, chat in target_chats.items()}
|
||||||
merged_data = {jid: chat.to_json() for jid, chat in target_chats.items()}
|
|
||||||
json.dump(merged_data, merged_file, indent=2)
|
# Check if the merged data differs from the original target data
|
||||||
|
if json.dumps(merged_data, sort_keys=True) != json.dumps(target_data, sort_keys=True):
|
||||||
|
print(f"Changes detected in {json_file}, updating target file...")
|
||||||
|
with open(target_path, 'w') as merged_file:
|
||||||
|
json.dump(merged_data, merged_file, indent=2)
|
||||||
|
else:
|
||||||
|
print(f"No changes detected in {json_file}, skipping update.")
|
||||||
|
|
||||||
# Merge media directories
|
# Merge media directories
|
||||||
source_media_path = os.path.join(source_dir, media_dir)
|
source_media_path = os.path.join(source_dir, media_dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user