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

Add Delta Update Support #122

Closed
mwbrooks opened this issue Jun 23, 2015 · 3 comments
Closed

Add Delta Update Support #122

mwbrooks opened this issue Jun 23, 2015 · 3 comments
Assignees

Comments

@mwbrooks
Copy link
Collaborator

Create a separate route that will serve an archive with only the changed files based on the session. When it is unclear what has changed, we can fallback on serving the entire archive (or nothing at all).

A suggestion route would be: /__api__/app/update

@mwbrooks
Copy link
Collaborator Author

I'm seeing the following error when a file has been changed:

[phonegap] 500 /__api__/update
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (http.js:690:11)
    at ServerResponse.res.setHeader (/Users/mwbrooks/Development/lib/connect-phonegap/node_modules/connect/lib/patch.js:63:22)
    at ServerResponse.<anonymous> (/Users/mwbrooks/Development/lib/connect-phonegap/node_modules/connect/lib/patch.js:80:14)
    at Array.forEach (native)
    at ServerResponse.res.writeHead (/Users/mwbrooks/Development/lib/connect-phonegap/node_modules/connect/lib/patch.js:79:28)
    at null.<anonymous> (/Users/mwbrooks/Development/lib/connect-phonegap/lib/middleware/update.js:65:21)
    at emit (events.js:117:20)
    at Archiver.append (/Users/mwbrooks/Development/lib/connect-phonegap/node_modules/archiver/lib/core.js:310:10)
    at Object.handle (/Users/mwbrooks/Development/lib/connect-phonegap/lib/middleware/update.js:92:29)
    at next (/Users/mwbrooks/Development/lib/connect-phonegap/node_modules/connect/lib/proto.js:193:15)

@mwbrooks
Copy link
Collaborator Author

The problem is that a new instance of archiver should be created on each creation of an archive. It cannot be reused:

https://github.com/phonegap/connect-phonegap/blob/quick-content-sync-updates/lib/middleware/update.js#L110-L113

@mwbrooks
Copy link
Collaborator Author

It's being reused to simplify testing that the archive is properly generated. We could simply to the test to not spy on the internals and instead focus on the input (GET request) and output (response).

For example, the test could take the form:

agent.get('/__api__/update')
         .expect('content-type', 'application/zip')
         .end(function(e, res) {
             // parse the response, inspect the ZIP, and ensure the expected files are returned
             done();
         });

There appears to be some details on reading the response buffer using supertest on this Stackoverflow article:
http://stackoverflow.com/questions/13573315/read-response-output-buffer-stream-with-supertest-superagent-on-node-js-server

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

No branches or pull requests

2 participants