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

check() never resolves if cordova-plugin-file is missing #97

Open
SystemParadox opened this issue May 11, 2016 · 2 comments
Open

check() never resolves if cordova-plugin-file is missing #97

SystemParadox opened this issue May 11, 2016 · 2 comments
Labels

Comments

@SystemParadox
Copy link

I am having trouble getting this to work and could use some advice on how to debug.

I've just knocked up a tiny simple app.js that does a check(), update(), download(), but it seems that check() never resolves on Android. Running directly in Chrome on desktop everything works as expected.

At the moment I'm just using the prebundled cordova-app-loader-complete.js. There's a call to

Promise.all([gotNewManifest, self.getBundledManifest(), self.cache.list()])

It seems that the self.cache.list() never resolves on Android.

What really confuses me is that nothing is showing up on the server log, even though the cordova app seems to be making successful XHR requests for manifest.json???

In case it helps, my app.js looks like this:

// Initialize a FileSystem
var fs = new CordovaPromiseFS({
    Promise: Promise
});

// Initialize a CordovaAppLoader
var loader = new CordovaAppLoader({
    fs: fs,
    serverRoot: 'http://custard:7771/',
    localRoot: 'app',
    cacheBuster: true, // make sure we're not downloading cached files.
    checkTimeout: 1000 // timeout for the "check" function - when you loose internet connection
});

document.body.innerHTML = '<div id="text"></div><div id="status"></div><button id="checkButton">Check</button><button id="updateButton">Update</button>';
document.getElementById('text').innerHTML = 'hello world 4';

setStatus('initial');

function setStatus(text) {
    document.getElementById('status').innerHTML = text;
    console.log('setStatus: ' + text);
}

function doCheck() {
    setStatus('checking');
    // download manifest from: serverRoot+'manifest.json'
    loader.check().then(function(updateAvailable) {
        if (updateAvailable) {
            setStatus('update available');
        } else {
            setStatus('no update available');
        }
    }, function (err) {
        setStatus('check failed');
        console.log('Failed to check: ' + err);
    });
}

function doUpdate() {
    setStatus('updating');
    function onProgress(progress) {
        setStatus('progress: ' + progress);
    }
    loader.download(onProgress).then(function (mainfest) {
        setStatus('download complete');
        loader.update();
    }, function (failedFiles) {
        setStatus('failed to download: ' + failedFiles.join(', '));
    });
}

document.getElementById('checkButton').addEventListener('click', doCheck);
document.getElementById('updateButton').addEventListener('click', doUpdate);
window.BOOTSTRAP_OK = true;

If anyone could give some tips on what to look for I would really appreciate it!

Thanks.

@SystemParadox
Copy link
Author

Ok this is fixed if I add the missing plugins:

cordova plugin add cordova-plugin-file
cordova plugin add cordova-plugin-file-transfer

However, that still doesn't explain why the promise was never resolved. I would have expected it to reject with an error instead of hanging forever. Is there something that can be done about this?

@SystemParadox SystemParadox changed the title Check never resolves on Android check() never resolves if cordova-plugin-file is missing May 11, 2016
@markmarijnissen
Copy link
Owner

I would expect an error that the FileSystem is never resolved.

I'll see if I can add this to the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants