Remove cache module exception

This commit is contained in:
topjohnwu 2017-10-01 01:38:25 +08:00
parent f6bcc84251
commit ab7fd9799d
5 changed files with 21 additions and 37 deletions

View File

@ -25,10 +25,8 @@ public class LoadModules extends ParallelTask<Void, Void, Void> {
for (String path : Utils.getModList(getShell(), MagiskManager.MAGISK_PATH)) {
Logger.dev("LoadModules: Adding modules from " + path);
try {
Module module = new Module(getShell(), path);
mm.moduleMap.put(module.getId(), module);
} catch (BaseModule.CacheModException ignored) {}
Module module = new Module(getShell(), path);
mm.moduleMap.put(module.getId(), module);
}
Logger.dev("LoadModules: Data load done");

View File

@ -68,21 +68,19 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
Date updatedDate = format.parse(lastUpdate);
Repo repo = repoDB.getRepo(id);
try {
Boolean updated;
if (repo == null) {
repo = new Repo(name, updatedDate);
updated = true;
} else {
// Popout from cached
cached.remove(id);
updated = repo.update(updatedDate);
}
if (updated) {
repoDB.addRepo(repo);
publishProgress();
}
} catch (BaseModule.CacheModException ignored) {}
Boolean updated;
if (repo == null) {
repo = new Repo(name, updatedDate);
updated = true;
} else {
// Popout from cached
cached.remove(id);
updated = repo.update(updatedDate);
}
if (updated) {
repoDB.addRepo(repo);
publishProgress();
}
}
}

View File

@ -38,9 +38,9 @@ public abstract class BaseModule implements Comparable<BaseModule> {
return values;
}
protected void parseProps(List<String> props) throws CacheModException { parseProps(props.toArray(new String[0])); }
protected void parseProps(List<String> props) { parseProps(props.toArray(new String[0])); }
protected void parseProps(String[] props) throws CacheModException {
protected void parseProps(String[] props) {
for (String line : props) {
String[] prop = line.split("=", 2);
if (prop.length != 2)
@ -75,9 +75,6 @@ public abstract class BaseModule implements Comparable<BaseModule> {
try {
templateVersion = Integer.parseInt(prop[1]);
} catch (NumberFormatException ignored) {}
case "cacheModule":
if (Boolean.parseBoolean(prop[1]))
throw new CacheModException(mId);
break;
default:
break;
@ -121,12 +118,6 @@ public abstract class BaseModule implements Comparable<BaseModule> {
return templateVersion;
}
public static class CacheModException extends Exception {
public CacheModException(String id) {
Logger.error("Cache mods are no longer supported! id: " + id);
}
}
@Override
public int compareTo(@NonNull BaseModule module) {
return this.getName().toLowerCase().compareTo(module.getName().toLowerCase());

View File

@ -9,7 +9,7 @@ public class Module extends BaseModule {
private String mRemoveFile, mDisableFile, mUpdateFile;
private boolean mEnable, mRemove, mUpdated;
public Module(Shell shell, String path) throws CacheModException {
public Module(Shell shell, String path) {
parseProps(Utils.readFile(shell, path + "/module.prop"));
@ -26,8 +26,6 @@ public class Module extends BaseModule {
setName(getId());
}
Logger.dev("Creating Module, id: " + getId());
mEnable = !Utils.itemExist(shell, mDisableFile);
mRemove = Utils.itemExist(shell, mRemoveFile);
mUpdated = Utils.itemExist(shell, mUpdateFile);

View File

@ -16,7 +16,7 @@ public class Repo extends BaseModule {
private String repoName;
private Date mLastUpdate;
public Repo(String name, Date lastUpdate) throws CacheModException {
public Repo(String name, Date lastUpdate) {
mLastUpdate = lastUpdate;
repoName = name;
update();
@ -28,14 +28,13 @@ public class Repo extends BaseModule {
mLastUpdate = new Date(c.getLong(c.getColumnIndex("last_update")));
}
public void update() throws CacheModException {
public void update() {
String props = WebService.getString(getManifestUrl());
String lines[] = props.split("\\n");
parseProps(lines);
Logger.dev("Repo: Fetching prop: " + getId());
}
public boolean update(Date lastUpdate) throws CacheModException {
public boolean update(Date lastUpdate) {
if (lastUpdate.after(mLastUpdate)) {
mLastUpdate = lastUpdate;
update();