From cb089aa4459d8b84fab3906693804724e70356c4 Mon Sep 17 00:00:00 2001 From: Gabriele M Date: Fri, 7 Jul 2017 22:36:45 +0200 Subject: [PATCH] Don't save the URL of the update in the database Each update must now be in updates.json to be downloaded. Since this file already stores the URL of each update and that the URL is not needed after the download, the URL entry can be removed from the database. --- src/org/lineageos/updater/UpdatesDbHelper.java | 7 ------- .../lineageos/updater/controller/UpdaterController.java | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesDbHelper.java b/src/org/lineageos/updater/UpdatesDbHelper.java index a7b793e..047bd0c 100644 --- a/src/org/lineageos/updater/UpdatesDbHelper.java +++ b/src/org/lineageos/updater/UpdatesDbHelper.java @@ -37,7 +37,6 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { public static final String COLUMN_NAME_PATH = "path"; public static final String COLUMN_NAME_NAME = "name"; public static final String COLUMN_NAME_DOWNLOAD_ID = "download_id"; - public static final String COLUMN_NAME_DOWNLOAD_URL = "download_url"; public static final String COLUMN_NAME_TIMESTAMP = "timestamp"; public static final String COLUMN_NAME_TYPE = "type"; public static final String COLUMN_NAME_VERSION = "version"; @@ -51,7 +50,6 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { UpdateEntry.COLUMN_NAME_PATH + " TEXT," + UpdateEntry.COLUMN_NAME_NAME + " TEXT," + UpdateEntry.COLUMN_NAME_DOWNLOAD_ID + " TEXT NOT NULL UNIQUE," + - UpdateEntry.COLUMN_NAME_DOWNLOAD_URL + " TEXT," + UpdateEntry.COLUMN_NAME_TIMESTAMP + " INTEGER," + UpdateEntry.COLUMN_NAME_TYPE + " TEXT," + UpdateEntry.COLUMN_NAME_VERSION + " TEXT," + @@ -84,7 +82,6 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { values.put(UpdateEntry.COLUMN_NAME_PATH, update.getFile().getAbsolutePath()); values.put(UpdateEntry.COLUMN_NAME_NAME, update.getName()); values.put(UpdateEntry.COLUMN_NAME_DOWNLOAD_ID, update.getDownloadId()); - values.put(UpdateEntry.COLUMN_NAME_DOWNLOAD_URL, update.getDownloadUrl()); values.put(UpdateEntry.COLUMN_NAME_TIMESTAMP, update.getTimestamp()); values.put(UpdateEntry.COLUMN_NAME_TYPE, update.getType()); values.put(UpdateEntry.COLUMN_NAME_VERSION, update.getVersion()); @@ -99,7 +96,6 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { values.put(UpdateEntry.COLUMN_NAME_PATH, update.getFile().getAbsolutePath()); values.put(UpdateEntry.COLUMN_NAME_NAME, update.getName()); values.put(UpdateEntry.COLUMN_NAME_DOWNLOAD_ID, update.getDownloadId()); - values.put(UpdateEntry.COLUMN_NAME_DOWNLOAD_URL, update.getDownloadUrl()); values.put(UpdateEntry.COLUMN_NAME_TIMESTAMP, update.getTimestamp()); values.put(UpdateEntry.COLUMN_NAME_TYPE, update.getType()); values.put(UpdateEntry.COLUMN_NAME_VERSION, update.getVersion()); @@ -165,7 +161,6 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { UpdateEntry.COLUMN_NAME_PATH, UpdateEntry.COLUMN_NAME_NAME, UpdateEntry.COLUMN_NAME_DOWNLOAD_ID, - UpdateEntry.COLUMN_NAME_DOWNLOAD_URL, UpdateEntry.COLUMN_NAME_TIMESTAMP, UpdateEntry.COLUMN_NAME_TYPE, UpdateEntry.COLUMN_NAME_VERSION, @@ -185,8 +180,6 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { update.setName(cursor.getString(index)); index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_DOWNLOAD_ID); update.setDownloadId(cursor.getString(index)); - index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_DOWNLOAD_URL); - update.setDownloadUrl(cursor.getString(index)); index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_TIMESTAMP); update.setTimestamp(cursor.getLong(index)); index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_TYPE); diff --git a/src/org/lineageos/updater/controller/UpdaterController.java b/src/org/lineageos/updater/controller/UpdaterController.java index 1902918..fa14593 100644 --- a/src/org/lineageos/updater/controller/UpdaterController.java +++ b/src/org/lineageos/updater/controller/UpdaterController.java @@ -320,6 +320,7 @@ public class UpdaterController implements UpdaterControllerInt { Log.d(TAG, "Download (" + update.getDownloadId() + ") already added"); UpdateDownload updateAdded = mDownloads.get(update.getDownloadId()).mUpdate; updateAdded.setAvailableOnline(availableOnline && updateAdded.getAvailableOnline()); + updateAdded.setDownloadUrl(update.getDownloadUrl()); return false; } if (!fixUpdateStatus(update) && !availableOnline) {