diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..683b324 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +defaults.local.js diff --git a/lib/gitea-sync.js b/lib/gitea-sync.js index 8755d91..daa7064 100644 --- a/lib/gitea-sync.js +++ b/lib/gitea-sync.js @@ -203,13 +203,13 @@ class SyncManager { static toFilename(name) { return name - .toLowerCase() .replace(/[äÄ]/g, 'ae') .replace(/[öÖ]/g, 'oe') .replace(/[üÜ]/g, 'ue') .replace(/ß/g, 'ss') - .replace(/[^a-z0-9]+/g, '-') - .replace(/^-+|-+$/g, ''); + .replace(/[/\\:*?"<>|]/g, '-') + .replace(/^[\s.-]+|[\s.-]+$/g, '') + .trim(); } /** @@ -291,7 +291,13 @@ class SyncManager { } } - await this.saveLocalTemplates(newTemplates); + // Merge: keep local-only templates that aren't now on the server + const existingTemplates = await this.getLocalTemplates(); + const pulledFilenames = new Set(newTemplates.map(t => SyncManager.toFilename(t.name).toLowerCase())); + const localOnly = existingTemplates.filter(t => !t.remotePath && !pulledFilenames.has(SyncManager.toFilename(t.name).toLowerCase())); + + const merged = [...newTemplates, ...localOnly]; + await this.saveLocalTemplates(merged); syncState.fileShas = newShas; await this.saveSyncState(syncState); diff --git a/templates_options/templates_options.html b/templates_options/templates_options.html index 3cff284..7404451 100644 --- a/templates_options/templates_options.html +++ b/templates_options/templates_options.html @@ -976,8 +976,10 @@