Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Commit

Permalink
Don't install same release as we are using right now. Reset internal …
Browse files Browse the repository at this point in the history
…preferences when app is updated via store. Needs more cleanup.

#229
  • Loading branch information
nikDemyankov committed Sep 27, 2016
1 parent ba3276f commit 164bb4e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,15 @@ private void installWwwFolder() {
// reset www folder installed flag
if (pluginInternalPrefs.isWwwFolderInstalled()) {
pluginInternalPrefs.setWwwFolderInstalled(false);
pluginInternalPrefs.setReadyForInstallationReleaseVersionName("");
pluginInternalPrefs.setPreviousReleaseVersionName("");

final ApplicationConfig appConfig = ApplicationConfig.configFromAssets(cordova.getActivity(), PluginFilesStructure.CONFIG_FILE_NAME);
pluginInternalPrefs.setCurrentReleaseVersionName(appConfig.getContentConfig().getReleaseVersion());

pluginInternalPrefsStorage.storeInPreference(pluginInternalPrefs);
}


AssetsHelper.copyAssetDirectoryToAppDirectory(cordova.getActivity().getApplicationContext(), WWW_FOLDER, fileStructure.getWwwFolder());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.nordnetab.chcp.main.config.ApplicationConfig;
import com.nordnetab.chcp.main.config.ContentManifest;
import com.nordnetab.chcp.main.events.NothingToInstallEvent;
import com.nordnetab.chcp.main.events.UpdateInstallationErrorEvent;
import com.nordnetab.chcp.main.events.UpdateInstalledEvent;
import com.nordnetab.chcp.main.events.WorkerEvent;
Expand Down Expand Up @@ -46,7 +45,7 @@ class InstallationWorker implements WorkerTask {
* @param newVersion version to install
* @param currentVersion current content version
*/
public InstallationWorker(final Context context, final String newVersion, final String currentVersion) {
InstallationWorker(final Context context, final String newVersion, final String currentVersion) {
newReleaseFS = new PluginFilesStructure(context, newVersion);
currentReleaseFS = new PluginFilesStructure(context, currentVersion);
}
Expand Down Expand Up @@ -74,7 +73,7 @@ public void run() {
deleteUnusedFiles();

// install the update
boolean isInstalled = moveFilesFromInstallationFolderToWwwFodler();
boolean isInstalled = moveFilesFromInstallationFolderToWwwFolder();
if (!isInstalled) {
cleanUpOnFailure();
setResultForError(ChcpError.FAILED_TO_COPY_NEW_CONTENT_FILES);
Expand Down Expand Up @@ -129,12 +128,6 @@ private boolean init() {
* @return <code>true</code> if files are copied; <code>false</code> - otherwise.
*/
private boolean copyFilesFromCurrentReleaseToNewRelease() {
//fix when app verlay installation,www content update filed
//error is code: -7, description: "Can't copy files from previous release to the new release"
if(currentReleaseFS != null && currentReleaseFS.getWwwFolder() != null
&& currentReleaseFS.getWwwFolder().equals(newReleaseFS.getWwwFolder())) {
return true;
}
boolean result = true;
final File currentWwwFolder = new File(currentReleaseFS.getWwwFolder());
final File newWwwFolder = new File(newReleaseFS.getWwwFolder());
Expand Down Expand Up @@ -183,7 +176,7 @@ private void deleteUnusedFiles() {
*
* @return <code>true</code> if files are copied; <code>false</code> - otherwise
*/
private boolean moveFilesFromInstallationFolderToWwwFodler() {
private boolean moveFilesFromInstallationFolderToWwwFolder() {
try {
FilesUtility.copy(newReleaseFS.getDownloadFolder(), newReleaseFS.getWwwFolder());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class UpdateLoaderWorker implements WorkerTask {
*
* @param request download request
*/
public UpdateLoaderWorker(final UpdateDownloadRequest request) {
UpdateLoaderWorker(final UpdateDownloadRequest request) {
applicationConfigUrl = request.getConfigURL();
appNativeVersion = request.getCurrentNativeVersion();
filesStructure = request.getCurrentReleaseFileStructure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public static ChcpError install(final Context context, final String newVersion,
return ChcpError.CANT_INSTALL_WHILE_DOWNLOAD_IN_PROGRESS;
}

// check, that download folder exists, and that we are not trying to install same release
final PluginFilesStructure newReleaseFS = new PluginFilesStructure(context, newVersion);
if (!new File(newReleaseFS.getDownloadFolder()).exists()) {
if (!new File(newReleaseFS.getDownloadFolder()).exists() || newVersion.equals(currentVersion)) {
return ChcpError.NOTHING_TO_INSTALL;
}

Expand Down

0 comments on commit 164bb4e

Please sign in to comment.