Fix/watch fs large json (#657)

* fix: large json import still need to check identity

* fix: show wiki server error by hide view

* fix: possible loop when image load failed

fixes https://github.com/tiddly-gittly/TidGi-Desktop/issues/562

* fix: more check and reduce logs

* fix: sub wiki no sync notification

fixes https://github.com/tiddly-gittly/TidGi-Desktop/issues/526

* fix: type

* fix: update git sync js

fixes https://github.com/tiddly-gittly/TidGi-Desktop/issues/515

* fix: msix not uploaded

* typo

* lint

* Update comparison.ts
This commit is contained in:
lin onetwo 2025-11-24 01:45:33 +08:00 committed by GitHub
parent ccf825af06
commit 45e3f76da1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 248 additions and 108 deletions

View file

@ -3,6 +3,7 @@ import fs from 'fs';
import nsfw from 'nsfw';
import path from 'path';
import type { IFileInfo, Tiddler, Wiki } from 'tiddlywiki';
import { hasMeaningfulChanges } from './comparison';
import { FileSystemAdaptor } from './FileSystemAdaptor';
import { type IBootFilesIndexItemWithTitle, InverseFilesIndex } from './InverseFilesIndex';
@ -623,8 +624,20 @@ export class WatchFileSystemAdaptor extends FileSystemAdaptor {
tiddlerTitle,
} as IBootFilesIndexItemWithTitle);
// Add tiddler to wiki (this will update if it exists or add if new)
// Get existing tiddler to check if content actually changed
const syncAdaptor = $tw.syncadaptor as { wiki: Wiki } | undefined | null;
const existingTiddler = syncAdaptor?.wiki.getTiddler(tiddlerTitle);
// Use content comparison to prevent unnecessary saves
// This is critical for large JSON imports that would otherwise cause infinite loops
if (existingTiddler) {
if (!hasMeaningfulChanges(existingTiddler.fields, tiddler)) {
// Content is identical, skip addTiddler to prevent save cycle
continue;
}
}
// Add tiddler to wiki (this will trigger save if content changed)
syncAdaptor?.wiki.addTiddler(tiddler);
// Log appropriate event