Here’s an improved and clearer version of the README: FolderSyncUtility
FolderSyncUtility is a Python-based tool that synchronizes files between a source folder and a replica folder. It periodically monitors the source folder for changes and updates the replica folder to reflect those changes. Features
File Synchronization: Copies files from the source folder to the replica folder.
Automatic Updates: Periodically checks for new files or changes in the source folder and applies them to the replica.
Logging: Logs all operations to a specified log file for easy tracking.
Graceful Termination: Can be safely stopped with termination signals (e.g., Ctrl+C), ensuring no incomplete sync operations.
Requirements
Python 3.x
Required packages (listed in requirements.txt)
Installation
Clone the repository:
git clone https://github.com/yourusername/FolderSyncUtility.git cd FolderSyncUtility
(Optional) Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
Install the required packages:
pip install -r requirements.txt
Usage
Run the program with the following command:
python3 main.py
<source>: Path to the source folder.
<replica>: Path to the replica folder.
<log_path>: Path to the log file.
<interval>: (Optional) Synchronization interval in seconds (default: 30 seconds).
Examples
python3 main.py source_folder replica_folder logs/sync.log
python3 main.py source_folder replica_folder logs/sync.log 60
How It Works
Initialization: The program initializes the logger and verifies that paths for the source, replica, and log file exist. If any path is missing, it creates the necessary directories.
Worker Threads: A worker thread is started for each file in the source folder. Each thread periodically reads its assigned file and synchronizes it with the corresponding file in the replica folder.
Continuous Monitoring: The program monitors the source folder for new or modified files, starting new worker threads as needed to handle these files.
Logging: All actions, such as file updates and errors, are recorded in the specified log file.
Handling Termination
The program can be safely stopped with Ctrl+C (or equivalent termination signals). This triggers a signal handler to clean up and exit the program gracefully, ensuring that ongoing operations complete before shutting down.