Only do backups before upgrade when necessary. Added a reminder comment in upgrade service to remind developers to do this

pull/14/head
Sam Bosley 12 years ago
parent 09f4d16aa1
commit 75b51c8839

@ -62,7 +62,7 @@ public class BackupActivity extends Activity {
setResult(RESULT_OK);
finish();
}
}, null);
}, null, null);
}
}

@ -78,7 +78,7 @@ public class BackupService extends Service {
}
TasksXmlExporter.exportTasks(context, TasksXmlExporter.ExportType.EXPORT_TYPE_SERVICE, null,
backupDirectorySetting.getBackupDirectory());
backupDirectorySetting.getBackupDirectory(), null);
} catch (Exception e) {
Log.e("error-backup", "Error starting backups", e); //$NON-NLS-1$ //$NON-NLS-2$

@ -46,9 +46,9 @@ public class TasksXmlExporter {
* @param backupDirectoryOverride new backupdirectory, or null to use default
*/
public static void exportTasks(Context context, ExportType exportType,
Runnable runAfterExport, File backupDirectoryOverride) {
Runnable runAfterExport, File backupDirectoryOverride, String versionName) {
new TasksXmlExporter(context, exportType, runAfterExport,
backupDirectoryOverride);
backupDirectoryOverride, versionName);
}
public static enum ExportType {
@ -83,12 +83,12 @@ public class TasksXmlExporter {
}
private TasksXmlExporter(final Context context, final ExportType exportType,
final Runnable runAfterExport, File backupDirectoryOverride) {
final Runnable runAfterExport, File backupDirectoryOverride, String versionName) {
this.context = context;
this.exportCount = 0;
this.backupDirectory = backupDirectoryOverride == null ?
BackupConstants.defaultExportDirectory() : backupDirectoryOverride;
this.latestSetVersionName = AstridPreferences.getCurrentVersionName();
this.latestSetVersionName = versionName;
handler = new Handler();
progressDialog = new ProgressDialog(context);

@ -34,7 +34,6 @@ import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
import com.todoroo.astrid.backup.BackupConstants;
import com.todoroo.astrid.backup.BackupService;
import com.todoroo.astrid.backup.TasksXmlExporter;
import com.todoroo.astrid.backup.TasksXmlImporter;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
@ -168,8 +167,6 @@ public class StartupService {
boolean justUpgraded = latestSetVersion != version;
if(justUpgraded && version > 0) {
if(latestSetVersion > 0) {
// Perform backup before upgrade
TasksXmlExporter.exportTasks(context, TasksXmlExporter.ExportType.EXPORT_TYPE_ON_UPGRADE, null, null);
upgradeService.performUpgrade(context, latestSetVersion);
}
AstridPreferences.setCurrentVersion(version);

@ -145,12 +145,17 @@ public final class UpgradeService {
else
dialog = null;
final String lastSetVersionName = AstridPreferences.getCurrentVersionName();
Preferences.setInt(AstridPreferences.P_UPGRADE_FROM, from);
new Thread(new Runnable() {
@Override
public void run() {
try {
// NOTE: This line should be uncommented whenever any new version requires a data migration
// TasksXmlExporter.exportTasks(context, TasksXmlExporter.ExportType.EXPORT_TYPE_ON_UPGRADE, null, null, lastSetVersionName);
if(from < V3_0_0)
new Astrid2To3UpgradeHelper().upgrade2To3(context, from);

Loading…
Cancel
Save