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.
This commit is contained in:
@@ -270,6 +270,9 @@ export class AutoSyncService {
|
||||
// @ts-ignore - syncedFiles exists in the JavaScript version
|
||||
const allSyncedScripts = await githubJsonService.getScriptsForFiles(syncResult.syncedFiles);
|
||||
|
||||
// Initialize script downloader service
|
||||
scriptDownloaderService.initializeConfig();
|
||||
|
||||
// Filter to only truly NEW scripts (not previously downloaded)
|
||||
const newScripts = [];
|
||||
for (const script of allSyncedScripts) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { writeFile, mkdir } from 'fs/promises';
|
||||
import { readFileSync, readdirSync } from 'fs';
|
||||
import { readFileSync, readdirSync, statSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
export class GitHubJsonService {
|
||||
@@ -84,11 +84,13 @@ export class GitHubJsonService {
|
||||
// Step 2: Get local file list (fast local operation)
|
||||
const localFiles = new Map();
|
||||
try {
|
||||
console.log(`Looking for local files in: ${this.localJsonDirectory}`);
|
||||
const localFileList = readdirSync(this.localJsonDirectory);
|
||||
console.log(`Found ${localFileList.length} files in local directory`);
|
||||
for (const fileName of localFileList) {
|
||||
if (fileName.endsWith('.json')) {
|
||||
const filePath = join(this.localJsonDirectory, fileName);
|
||||
const stats = require('fs').statSync(filePath);
|
||||
const stats = statSync(filePath);
|
||||
localFiles.set(fileName, {
|
||||
mtime: stats.mtime,
|
||||
size: stats.size
|
||||
@@ -96,6 +98,8 @@ export class GitHubJsonService {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error reading local directory:', error.message);
|
||||
console.log('Directory path:', this.localJsonDirectory);
|
||||
console.log('No local files found, will download all');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user