Tarek you make some good points. I thought about making it a thread because I certainly don't want it to block the entire application in case some resource was unavailable (i.e. an external hard drive). A few questions/comments:
1. Do you think it's necessary to allow a user to store more than one backup? I can either add a checkbox to SettingsDlg.ui (which means true or false it is going to take a backup when the database is opened), or I can add in a QSpinBox so that the user can specify some rolling number of backups to keep (which allows a "history" of the database in some sense). Perhaps some of the users here can voice their opinion, but I'm starting to wonder whether or not multiple backups are really necessary. I'm leaning towards allowing only one backup at the moment.
2. In regard to the abstraction layer, I'm thinking that in order to implement this I would create a "Backup" class that would be the parent (actually...I believe Backup would be a child of QThread). Then we could define new children for each implementation of backups. I was not planning on offering more than a simple filesystem backup, though perhaps later it would be possible to say something like
- Code: Select all
SCPBackup : Backup {
// run method here would call the scp command instead
}
Then a new option can be added later to the SettingsDlg.ui which specifies
how the backup will actually be done. Selecting this new option would cause a new child of Backup (such as SCPBackup) to call their unique run() method which does the backup via scp. Does this sound reasonable then?
3. As far a queue of backups to be run, I was thinking of having the thread sleep while the resource it was waiting on is unavailable. For example, if it were waiting on some network resource (such as a mount point to become available) it would just sleep. So something like:
- Code: Select all
while (!mountPointAvailable()) {
sleep(5000);
}
// once it gets here then the thread saves
I suppose in this case it would be possible for the second thread to obtain and write the resource first. For example, it's possible that we open database1.kdb. While it's waiting for a network drive, we open database2.kdb. The thread to write database2.kdb finds the resource and makes a backup, and then the thread to write database1.kdb finds the resource and makes a backup. So order is not necessarily preserved, but since it's a new thread it should not be blocking the keepassx process from going about its business. So I'm not entirely sure if a queue is necessary..???