Skip to content

Commit a6a02a1

Browse files
fix: Auto-sync file detection and script downloader initialization
- Fixed statSync import in githubJsonService.js - Added proper initialization of scriptDownloaderService before use - Fixed local file detection - now correctly finds 411 local files instead of 0 - Auto-sync now properly shows 'Files to sync: 0, Up-to-date: 404' instead of downloading all - Added debugging output to track file detection process The auto-sync now correctly detects existing files and only syncs what's actually new or changed.
1 parent bf5b602 commit a6a02a1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/server/services/autoSyncService.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ export class AutoSyncService {
270270
// @ts-ignore - syncedFiles exists in the JavaScript version
271271
const allSyncedScripts = await githubJsonService.getScriptsForFiles(syncResult.syncedFiles);
272272

273+
// Initialize script downloader service
274+
scriptDownloaderService.initializeConfig();
275+
273276
// Filter to only truly NEW scripts (not previously downloaded)
274277
const newScripts = [];
275278
for (const script of allSyncedScripts) {

src/server/services/githubJsonService.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { writeFile, mkdir } from 'fs/promises';
2-
import { readFileSync, readdirSync } from 'fs';
2+
import { readFileSync, readdirSync, statSync } from 'fs';
33
import { join } from 'path';
44

55
export class GitHubJsonService {
@@ -84,18 +84,22 @@ export class GitHubJsonService {
8484
// Step 2: Get local file list (fast local operation)
8585
const localFiles = new Map();
8686
try {
87+
console.log(`Looking for local files in: ${this.localJsonDirectory}`);
8788
const localFileList = readdirSync(this.localJsonDirectory);
89+
console.log(`Found ${localFileList.length} files in local directory`);
8890
for (const fileName of localFileList) {
8991
if (fileName.endsWith('.json')) {
9092
const filePath = join(this.localJsonDirectory, fileName);
91-
const stats = require('fs').statSync(filePath);
93+
const stats = statSync(filePath);
9294
localFiles.set(fileName, {
9395
mtime: stats.mtime,
9496
size: stats.size
9597
});
9698
}
9799
}
98100
} catch (error) {
101+
console.log('Error reading local directory:', error.message);
102+
console.log('Directory path:', this.localJsonDirectory);
99103
console.log('No local files found, will download all');
100104
}
101105

0 commit comments

Comments
 (0)