Skip to content

raincatcher-file enhancements - #15

Closed
col1985 wants to merge 9 commits into
raincatcher-beta:masterfrom
col1985:master
Closed

raincatcher-file enhancements#15
col1985 wants to merge 9 commits into
raincatcher-beta:masterfrom
col1985:master

Conversation

@col1985

@col1985 col1985 commented Mar 14, 2017

Copy link
Copy Markdown
  • Added fileSystem module for reading and writing files to local fileSystem
  • Added ftp queue CRUD module for managing file transfer items

@nialldonnellyfh nialldonnellyfh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Generally looks good. Added some comments.

  • Needs some unit tests for the queue etc.
  • Also, can you add some comments to the new functions in the file

@wtrocki When you get a chance, can you also take a look as this will need to move to your refactor. Would be good to get your input.

Comment thread lib/fileSystem.js Outdated

function _requestFileSystem() {
var d = q.defer();
navigator.webkitPersistentStorage.requestQuota(1024 * 1024, function(grantedBytes) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will work fine in the browser, but not on mobile device.

This file (https://github.com/feedhenry/fh-js-sdk/blob/master/src/appforms/src/core/020-utils01fileSystem.js#L377) might prove useful for switching between available file systems.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

thanks I will make the adjustment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Best to use local storage adapter which would switch to be best adapter available on the device. Example from our JS SDK: https://github.com/feedhenry/fh-js-sdk/tree/master/libs/lawnchair

Comment thread lib/fileSystem.js
fileSystem.readFile = function(name) {
var deferredRead = q.defer();

if (fileSystem.ready) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is no else here. The promise will never resolve.

Comment thread lib/file.js Outdated
}

client.initPromise = q.all([deferredFhinit.promise, deferredReady.promise]);
var deferredInitQueues = q.defer();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should there be one for the config.queue.downloadsLabel also?

Comment thread lib/fileSystem.js
var deferredWrite = q.defer();
var fileData = JSON.stringify(data);

if (fileSystem.ready) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is no else here, the promise will never resolve.

You might consider adding a promise to the fileSystem.init function to return a promise instead of setting a ready flag.

In that case, anything using that promise would immediately reject with a useful error message.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Makes sense, il make the change

Comment thread lib/file.js
}
};

client.processQueue = function() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where is this function called from? It it called from the application consuming the module?

@col1985 col1985 Mar 15, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, the intention is to call this function from the app.js or where ever the developer would prefer. There is also an expectation the developer will handle offline and online events, saving and processing the queue as needed.

I will update README detailing this. What do you think?

Comment thread lib/queue.js Outdated
q = require('q'),
_ = require('lodash');

// meta data item model schema

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are all of these fields required for the file upload?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@nialldonnellyfh do you mean proposed model? This was just an example., however I have considered adding validations on required fields.

Comment thread lib/fileSystem.js Outdated
var msg = '';

switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This would crash on modern webview. See: brianleroux/lawnchair#229

@wtrocki

wtrocki commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

PR looks ok, but module is under heavy refactoring.. I'm going to bring this changes into new component once it's finished. I would also adapt changes to make them more generic etc.

@wtrocki

wtrocki commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

@nialldonnellyfh Going to create ticket to make sure that this work would be tracked in jira.
@col1985 Can you explain more what means:
Added ftp queue CRUD module for managing file transfer items

@wtrocki

wtrocki commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

@col1985 Created https://issues.jboss.org/browse/RAINCATCH-636
Feel free to provide more details and requirements for this work directly in the jira.
For example: Do we need to have UI for uploading and downloading data? etc.
I'm going to replicate your changes once we finish our migration.

@col1985

col1985 commented Mar 15, 2017

Copy link
Copy Markdown
Author

Thanks, @wtrocki I will update the ticket shortly. I am currently writing some unit tests for the Queue and fileSystem modules.

@wtrocki based off @nialldonnellyfh feedback earlier, I have added downloadFile and retryDownloadFile functions to file.js. Is this required or will you cover this in your refactor?

@wtrocki

wtrocki commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

@col1985 I would take care of the integration part. Let's make sure that all requirements are in jira.

@col1985

col1985 commented Mar 16, 2017

Copy link
Copy Markdown
Author

@nialldonnellyfh @wtrocki Would someone be ale to review PR today?

@wtrocki

wtrocki commented Mar 16, 2017

Copy link
Copy Markdown
Contributor

@col1985 I did reviewed this, but there is no point to integrate changes as I would need manually adapt changes to new structure and verify them. Leave that with us.

@col1985

col1985 commented Mar 16, 2017

Copy link
Copy Markdown
Author

@wtrocki perfect thanks

@col1985

col1985 commented Mar 22, 2017

Copy link
Copy Markdown
Author

Closing PR as I have made a number of changes since I plan to resubmit cleaner PR at a later date.

@col1985 col1985 closed this Mar 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants