diff --git a/src/app/_components/GeneralSettingsModal.tsx b/src/app/_components/GeneralSettingsModal.tsx
index d351709..94c4589 100644
--- a/src/app/_components/GeneralSettingsModal.tsx
+++ b/src/app/_components/GeneralSettingsModal.tsx
@@ -885,6 +885,8 @@ export function GeneralSettingsModal({ isOpen, onClose }: GeneralSettingsModalPr
value={syncIntervalCron}
onChange={(e) => handleCronChange(e.target.value)}
className="w-full"
+ autoFocus
+ onFocus={() => setCronValidationError('')}
/>
{cronValidationError && (
{cronValidationError}
@@ -896,6 +898,16 @@ export function GeneralSettingsModal({ isOpen, onClose }: GeneralSettingsModalPr
{' '}
for examples
+
+
Common examples:
+
+ - •
* * * * * - Every minute
+ - •
0 * * * * - Every hour
+ - •
0 */6 * * * - Every 6 hours
+ - •
0 0 * * * - Every day at midnight
+ - •
0 0 * * 0 - Every Sunday at midnight
+
+
)}
diff --git a/src/app/api/settings/auto-sync/route.ts b/src/app/api/settings/auto-sync/route.ts
index 7a8a775..231e0d7 100644
--- a/src/app/api/settings/auto-sync/route.ts
+++ b/src/app/api/settings/auto-sync/route.ts
@@ -71,7 +71,7 @@ export async function POST(request: NextRequest) {
);
}
- if (!isValidCron(settings.syncIntervalCron)) {
+ if (!isValidCron(settings.syncIntervalCron, { seconds: false })) {
return NextResponse.json(
{ error: 'Invalid cron expression' },
{ status: 400 }
@@ -158,6 +158,23 @@ export async function POST(request: NextRequest) {
// Write back to .env file
fs.writeFileSync(envPath, envContent);
+ // Reschedule auto-sync service with new settings
+ try {
+ const { AutoSyncService } = await import('../../../../server/services/autoSyncService.js');
+ const autoSyncService = new AutoSyncService();
+
+ if (settings.autoSyncEnabled) {
+ autoSyncService.scheduleAutoSync();
+ console.log('Auto-sync rescheduled with new settings');
+ } else {
+ autoSyncService.stopAutoSync();
+ console.log('Auto-sync stopped');
+ }
+ } catch (error) {
+ console.error('Error rescheduling auto-sync service:', error);
+ // Don't fail the request if rescheduling fails
+ }
+
return NextResponse.json({
success: true,
message: 'Auto-sync settings saved successfully'
diff --git a/src/server/services/autoSyncService.js b/src/server/services/autoSyncService.js
index d23e760..0cb807b 100644
--- a/src/server/services/autoSyncService.js
+++ b/src/server/services/autoSyncService.js
@@ -191,8 +191,8 @@ export class AutoSyncService {
cronExpression = intervalMap[settings.syncIntervalPredefined] || '0 * * * *';
}
- // Validate cron expression
- if (!cronValidator.isValidCron(cronExpression)) {
+ // Validate cron expression (5-field format for node-cron)
+ if (!cronValidator.isValidCron(cronExpression, { seconds: false })) {
console.error('Invalid cron expression:', cronExpression);
return;
}