Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corrupted ccz handling #779

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look into deleting the file on disk.

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