OpenDelta: delete initial file only on flashing

Some people build images but dont flash them
If we delete the initial file right after building
its not possible to do a delta update again the
next day but only a full download.

Only disadvantage is space requirement for an
additional image that we may keep around

Change-Id: I4fd37d69ce48e76ecc2167fe6a6d9fa5c604a5fd
This commit is contained in:
maxwen 2015-08-12 21:35:58 +02:00
parent 954a51d27e
commit 507044bfc1
1 changed files with 20 additions and 4 deletions

View File

@ -184,6 +184,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
public static final String PREF_STOP_DOWNLOAD = "stop_download";
public static final String PREF_DOWNLOAD_SIZE = "download_size";
public static final String PREF_DELTA_SIGNATURE = "delta_signature";
public static final String PREF_INITIAL_FILE = "initial_file";
public static final int PREF_AUTO_DOWNLOAD_DISABLED = 0;
public static final int PREF_AUTO_DOWNLOAD_CHECK = 1;
@ -1456,6 +1457,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
boolean deltaSignature = prefs.getBoolean(PREF_DELTA_SIGNATURE, false);
String flashFilename = prefs.getString(PREF_READY_FILENAME_NAME, PREF_READY_FILENAME_DEFAULT);
String intialFile = prefs.getString(PREF_INITIAL_FILE, PREF_READY_FILENAME_DEFAULT);
clearState();
@ -1463,6 +1465,12 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
|| !flashFilename.startsWith(config.getPathBase()))
return;
// now delete the initial file
if (intialFile != null
&& new File(intialFile).exists()
&& intialFile.startsWith(config.getPathBase())){
new File(intialFile).delete();
}
// Remove the path to the storage from the filename, so we get a path
// relative to the root of the storage
String path_sd = Environment.getExternalStorageDirectory()
@ -1733,6 +1741,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
prefs.edit().putString(PREF_READY_FILENAME_NAME, PREF_READY_FILENAME_DEFAULT).commit();
prefs.edit().putString(PREF_DOWNLOAD_SIZE, null).commit();
prefs.edit().putBoolean(PREF_DELTA_SIGNATURE, false).commit();
prefs.edit().putString(PREF_INITIAL_FILE, PREF_READY_FILENAME_DEFAULT).commit();
}
private void shouldShowErrorNotification() {
@ -1754,11 +1763,14 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
wakeLock.acquire();
wifiLock.acquire();
String notificationText = getString(R.string.state_action_checking);
if (checkOnly > PREF_AUTO_DOWNLOAD_CHECK) {
notificationText = getString(R.string.state_action_downloading);
}
Notification notification = (new Notification.Builder(this)).
setSmallIcon(R.drawable.stat_notify_update).
setContentTitle(getString(R.string.title)).
setContentText(getString(R.string.notify_checking)).
setTicker(getString(R.string.notify_checking)).
setContentText(notificationText).
setShowWhen(false).
setContentIntent(getNotificationIntent(false)).
build();
@ -2055,9 +2067,13 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
if (di != lastDelta)
(new File(config.getPathBase() + di.getOut().getName())).delete();
}
// we will not delete initialFile until flashing
// else people building images and not flashing for 24h will loose
// the possibility to do delta updates
if (initialFile != null) {
if (initialFile.startsWith(config.getPathBase()))
(new File(initialFile)).delete();
if (initialFile.startsWith(config.getPathBase())) {
prefs.edit().putString(PREF_INITIAL_FILE, initialFile).commit();
}
}
prefs.edit().putBoolean(PREF_DELTA_SIGNATURE, true).commit();
prefs.edit().putString(PREF_READY_FILENAME_NAME, flashFilename).commit();