- Added scan_interval parameter to FolderWatcher class - Implemented _periodic_scan background thread - Fixed on_modified event handler to process files - Improved logging for debugging filesystem events - Optimized _process_existing to avoid redundant processing
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
import sys
|
|
import threading
|
|
from pathlib import Path
|
|
|
|
# Add project root to path
|
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
|
|
from core import init_config, Database, FileProcessor, TelegramNotifier, FolderWatcher
|
|
from web.app import init_web
|
|
|
|
def main():
|
|
# Initialize config (creates example if not exists)
|
|
config = init_config()
|
|
|
|
# Initialize database
|
|
db = Database(config['database']['path'])
|
|
|
|
# Initialize notifier
|
|
notifier = TelegramNotifier(config)
|
|
|
|
# Initialize processor
|
|
processor = FileProcessor(config, db, notifier)
|
|
|
|
# Start web UI in background thread
|
|
app = init_web(db, config, processor)
|
|
flask_thread = threading.Thread(
|
|
target=lambda: app.run(host='0.0.0.0', port=5000, debug=False),
|
|
daemon=True
|
|
)
|
|
flask_thread.start()
|
|
print("Web UI started at http://localhost:5000")
|
|
|
|
# Start file watcher (blocking)
|
|
watcher = FolderWatcher(config['general']['drop_folder'], processor, scan_interval=config['general']['scan_interval'])
|
|
watcher.start()
|
|
|
|
if __name__ == '__main__':
|
|
main() |