Skip to content

Commit

Permalink
VFS: DropboxAPI now has timeout for auth (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Dec 19, 2015
1 parent eb91262 commit e3af543
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/client/javascript/locales/en_EN.js
Expand Up @@ -65,6 +65,9 @@
'ERR_APP_MISSING_ARGUMENT_FMT': 'Missing argument: {0}',
'ERR_APP_UNKNOWN_ERROR' : 'Unknown error',

'ERR_OPERATION_TIMEOUT' : 'Operation Timeout',
'ERR_OPERATION_TIMEOUT_FMT' : 'Operation Timeout ({0})',

// Window
'ERR_WIN_DUPLICATE_FMT' : 'You already have a Window named \'{0}\'',
'WINDOW_MINIMIZE' : 'Minimize',
Expand Down
20 changes: 15 additions & 5 deletions src/client/javascript/vfs/dropbox.js
Expand Up @@ -94,9 +94,19 @@
}

DropboxVFS.prototype.init = function(callback) {
var timedOut = false;

var timeout = setTimeout(function() {
timedOut = true;
callback(API._('ERR_OPERATION_TIMEOUT_FMT', '60s'));
}, 60*1000);

this.client.authenticate(function(error, client) {
console.warn('DropboxVFS::construct()', error, client);
callback(error);
if ( !timedOut ) {
console.warn('DropboxVFS::construct()', error, client);
timeout = clearTimeout(timeout);
callback(error);
}
});
};

Expand Down Expand Up @@ -272,7 +282,7 @@
_cachedClient.init(function(error) {
if ( error ) {
console.error('Failed to initialize dropbox VFS', error);
callback(null);
callback(null, error);
return;
}

Expand Down Expand Up @@ -326,9 +336,9 @@
args = args || [];
callback = callback || function() {};

getDropbox(function(instance) {
getDropbox(function(instance, error) {
if ( !instance ) {
callback('No Dropbox VFS API Instance was ever created. Possible intialization error');
callback('No Dropbox VFS API Instance was ever created. Possible intialization error' + (error ? ': ' + error : ''));
return;
}
var fargs = args;
Expand Down

0 comments on commit e3af543

Please sign in to comment.