1
Fork 0

Added list comparison statement, check if anything has changed

This commit is contained in:
Jake Howard 2014-07-25 19:08:48 +01:00
parent 1b3f83d9e1
commit 4c7a7373b4

View file

@ -14,15 +14,23 @@ namespace Saviour_Backup_System
public static void initDriveScan(){ public static void initDriveScan(){
Timer scanTimer = new Timer(); Timer scanTimer = new Timer();
scanTimer.Elapsed += new ElapsedEventHandler(driveScanTick); scanTimer.Elapsed += new ElapsedEventHandler(driveScanTick);
scanTimer.Interval = 5000; scanTimer.Interval = 1000 * 7; //seconds to check for new drives
scanTimer.Start(); scanTimer.Start();
} }
private static List<string> connectedDrives;
private static void driveScanTick(object sender, ElapsedEventArgs e) private static void driveScanTick(object sender, ElapsedEventArgs e)
{ {
List<string> drivesSnapshot = connectedDrives;
DriveInfo[] drives = getConnectedDrives(); DriveInfo[] drives = getConnectedDrives();
foreach (DriveInfo drive in drives) foreach (DriveInfo drive in drives)
{ {
//open database, check if record backup record exists. If so, then run backup procedure in seperate thread connectedDrives.Add(drive.VolumeLabel);
}
if (connectedDrives.All(item => drivesSnapshot.Contains(item)) &&
drivesSnapshot.All(item => connectedDrives.Contains(item))) {
return;
} else {
//check if record exists in database
} }
} }
public static DriveInfo[] getConnectedDrives() public static DriveInfo[] getConnectedDrives()