Fix repeated unlock requests, probably (and remove old request limiting code, which was never finished)

This commit is contained in:
Dan Stillman 2009-03-14 22:13:20 +00:00
parent d904470200
commit f0def44c29

View File

@ -737,8 +737,6 @@ Zotero.Sync.Server = new function () {
var _serverURL = ZOTERO_CONFIG.SYNC_URL; var _serverURL = ZOTERO_CONFIG.SYNC_URL;
var _apiVersionComponent = "version=" + this.apiVersion; var _apiVersionComponent = "version=" + this.apiVersion;
var _maxAttempts = 3;
var _attempts = _maxAttempts;
var _cachedCredentials = {}; var _cachedCredentials = {};
var _syncInProgress; var _syncInProgress;
var _sessionID; var _sessionID;
@ -802,10 +800,6 @@ Zotero.Sync.Server = new function () {
function sync(callback) { function sync(callback) {
Zotero.Sync.Runner.setSyncIcon('animate'); Zotero.Sync.Runner.setSyncIcon('animate');
if (_attempts < 0) {
_error('Too many attempts in Zotero.Sync.Server.sync()');
}
if (!_sessionID) { if (!_sessionID) {
Zotero.debug("Session ID not available -- logging in"); Zotero.debug("Session ID not available -- logging in");
Zotero.Sync.Server.login(Zotero.Sync.Server.sync, callback); Zotero.Sync.Server.login(Zotero.Sync.Server.sync, callback);
@ -1064,8 +1058,6 @@ Zotero.Sync.Server = new function () {
finally { finally {
Zotero.UnresponsiveScriptIndicator.enable(); Zotero.UnresponsiveScriptIndicator.enable();
} }
_resetAttempts();
}); });
return; return;
@ -1075,10 +1067,6 @@ Zotero.Sync.Server = new function () {
function lock(callback, callbackCallback) { function lock(callback, callbackCallback) {
Zotero.debug("Getting session lock"); Zotero.debug("Getting session lock");
if (_attempts < 0) {
_error('Too many attempts in Zotero.Sync.Server.lock()', 2);
}
if (!_sessionID) { if (!_sessionID) {
_error('No session available in Zotero.Sync.Server.lock()', 2); _error('No session available in Zotero.Sync.Server.lock()', 2);
} }
@ -1134,10 +1122,6 @@ Zotero.Sync.Server = new function () {
function unlock(callback) { function unlock(callback) {
Zotero.debug("Releasing session lock"); Zotero.debug("Releasing session lock");
if (_attempts < 0) {
_error('Too many attempts in Zotero.Sync.Server.unlock()');
}
if (!_sessionID) { if (!_sessionID) {
_error('No session available in Zotero.Sync.Server.unlock()'); _error('No session available in Zotero.Sync.Server.unlock()');
} }
@ -1156,10 +1140,12 @@ Zotero.Sync.Server = new function () {
var response = xmlhttp.responseXML.childNodes[0]; var response = xmlhttp.responseXML.childNodes[0];
if (response.firstChild.tagName == 'error') { if (response.firstChild.tagName == 'error') {
_sessionLock = null;
_error(response.firstChild.firstChild.nodeValue); _error(response.firstChild.firstChild.nodeValue);
} }
if (response.firstChild.tagName != 'unlocked') { if (response.firstChild.tagName != 'unlocked') {
_sessionLock = null;
_error('Invalid response from server', xmlhttp.responseText); _error('Invalid response from server', xmlhttp.responseText);
} }
@ -1173,10 +1159,6 @@ Zotero.Sync.Server = new function () {
function clear(callback) { function clear(callback) {
if (_attempts < 0) {
_error('Too many attempts in Zotero.Sync.Server.clear()');
}
if (!_sessionID) { if (!_sessionID) {
Zotero.debug("Session ID not available -- logging in"); Zotero.debug("Session ID not available -- logging in");
Zotero.Sync.Server.login(Zotero.Sync.Server.clear, callback); Zotero.Sync.Server.login(Zotero.Sync.Server.clear, callback);
@ -1213,8 +1195,6 @@ Zotero.Sync.Server = new function () {
callback(); callback();
} }
}); });
_resetAttempts();
} }
@ -1222,10 +1202,6 @@ Zotero.Sync.Server = new function () {
* Clear session lock on server * Clear session lock on server
*/ */
function resetServer(callback) { function resetServer(callback) {
if (_attempts < 0) {
_error('Too many attempts in Zotero.Sync.Server.resetServer()');
}
if (!_sessionID) { if (!_sessionID) {
Zotero.debug("Session ID not available -- logging in"); Zotero.debug("Session ID not available -- logging in");
Zotero.Sync.Server.login(Zotero.Sync.Server.resetServer, callback); Zotero.Sync.Server.login(Zotero.Sync.Server.resetServer, callback);
@ -1264,8 +1240,6 @@ Zotero.Sync.Server = new function () {
callback(); callback();
} }
}); });
_resetAttempts();
} }
@ -1399,11 +1373,6 @@ Zotero.Sync.Server = new function () {
} }
function _resetAttempts() {
_attempts = _maxAttempts;
}
function _error(e, extraInfo) { function _error(e, extraInfo) {
if (extraInfo) { if (extraInfo) {
// Server errors will generally be HTML // Server errors will generally be HTML
@ -1414,7 +1383,6 @@ Zotero.Sync.Server = new function () {
Zotero.debug(e, 1); Zotero.debug(e, 1);
_syncInProgress = false; _syncInProgress = false;
_resetAttempts();
Zotero.DB.rollbackAllTransactions(); Zotero.DB.rollbackAllTransactions();
Zotero.reloadDataObjects(); Zotero.reloadDataObjects();