mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-24 05:21:02 -08:00
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:
parent
ccf825af06
commit
45e3f76da1
14 changed files with 248 additions and 108 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue