Do a sync
| 761 | |
| 762 | // Do a sync |
| 763 | int CmdLineTool::sync() { |
| 764 | if (!global.accountsManager->oauthTokenFound()) { |
| 765 | std::cout << tr("OAuth token not found.").toStdString() << endl; |
| 766 | return 16; |
| 767 | } |
| 768 | |
| 769 | global.db = new DatabaseConnection("nixnote"); // Startup the database |
| 770 | |
| 771 | // Check if the table exists. If not, create it. |
| 772 | NSqlQuery sql(global.db); |
| 773 | sql.exec("Select * from sqlite_master where type='table' and name='NoteTable';"); |
| 774 | if (!sql.next()) { |
| 775 | NoteModel model(this); |
| 776 | model.createTable(); |
| 777 | } |
| 778 | sql.finish(); |
| 779 | |
| 780 | SyncRunner runner; |
| 781 | runner.synchronize(); |
| 782 | if (runner.error) { |
| 783 | std::cout << tr("Error synchronizing with Evernote.").toStdString() << std::endl; |
| 784 | return 16; |
| 785 | } |
| 786 | std::cout << tr("Sync completed.").toStdString() << std::endl; |
| 787 | return 0; |
| 788 | } |
| 789 | |
| 790 | |
| 791 |
no test coverage detected