Skip to content

Commit

Permalink
corrupted ccz handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Nguyen committed Nov 6, 2020
1 parent ee6f3f6 commit 617de50
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/commcare
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ public Reference derive(String guidPath) throws InvalidReferenceException {
throw new InvalidReferenceException(String.format("Error deriving reference with exception %s.", guidPath), guidPath);
}
}

@Override
public String removeArchiveFile(String appId) {
String mGUID = super.removeArchiveFile(appId);
redisTemplate.delete(String.format("formplayer:archive:%s", mGUID));
return mGUID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public FormplayerConfigEngine(IStorageIndexedFactory storageFactory,
ReferenceManager.instance().addReferenceFactory(formplayerArchiveFileRoot);
}

private String parseAppId(String url) {
public static String parseAppId(String url) {
String appId = null;
try {
List<NameValuePair> params = new URIBuilder(url).getQueryParams();
Expand Down Expand Up @@ -105,6 +105,11 @@ public void initFromArchive(String archiveURL, boolean preview) throws InstallCa
init("jr://archive/" + archiveGUID + "/profile.ccpr");
}

public void removeArchive(String archiveURL) {
String appId = parseAppId(archiveURL);
mArchiveRoot.removeArchiveFile(appId);
}

@Override
protected String downloadToTemp(String resource) {
FileOutputStream fos = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.commcare.formplayer.util.Constants;
import org.commcare.formplayer.util.SimpleTimer;


/**
* The InstallService handles configuring the application,
* either from a .ccz or .ccpr reference or existing dbs.
Expand Down Expand Up @@ -84,10 +85,12 @@ public Pair<FormplayerConfigEngine, Boolean> configureApplication(String referen
return new Pair<>(engine, newInstall);
} catch (UnresolvedResourceException e) {
log.error("Got exception " + e + " while installing reference " + reference + " at path " + sqliteDB.getDatabaseFileForDebugPurposes());
formplayerArchiveFileRoot.removeArchiveFile(FormplayerConfigEngine.parseAppId(reference));
throw new UnresolvedResourceRuntimeException(e);
} catch (Exception e) {
log.error("Got exception " + e + " while installing reference " + reference + " at path " + sqliteDB.getDatabaseFileForDebugPurposes());
sqliteDB.deleteDatabaseFile();
formplayerArchiveFileRoot.removeArchiveFile(FormplayerConfigEngine.parseAppId(reference));
throw e;
}
}
Expand Down

0 comments on commit 617de50

Please sign in to comment.