CSL update fix for 1.0.4

Added ability to delete CSLs from repo
This commit is contained in:
Dan Stillman 2008-05-12 16:16:17 +00:00
parent a807c67149
commit ca02de39fd

View File

@ -203,14 +203,13 @@ Zotero.Schema = new function(){
* since the last check * since the last check
**/ **/
function updateScrapersRemote(force, callback) { function updateScrapersRemote(force, callback) {
// Little hack to manually update from repo on upgrade to 1.0.3 // Little hack to manually update CSLs from repo on upgrades
if (!force && Zotero.Prefs.get('automaticScraperUpdates')) { if (!force && Zotero.Prefs.get('automaticScraperUpdates')) {
var syncTargetVersion = 2; // increment this when releasing new version that requires it var syncTargetVersion = 3; // increment this when releasing new version that requires it
var syncVersion = _getDBVersion('sync'); var syncVersion = _getDBVersion('sync');
if (syncVersion < syncTargetVersion) { if (syncVersion < syncTargetVersion) {
_updateDBVersion('sync', syncTargetVersion);
force = true; force = true;
var uriChangeFix = true; var forceCSLUpdate = true;
} }
} }
@ -267,9 +266,9 @@ Zotero.Schema = new function(){
url += '&m=1'; url += '&m=1';
} }
// Fix for styles with new URIs in 1.0.3 // Force updating of all public CSLs
if (uriChangeFix) { if (forceCSLUpdate) {
url += '&urifix=1'; url += '&cslup=' + syncTargetVersion;
} }
} }
@ -636,6 +635,17 @@ Zotero.Schema = new function(){
Zotero.DB.beginTransaction(); Zotero.DB.beginTransaction();
try {
var re = /cslup=([0-9]+)/;
var matches = re.exec(xmlhttp.channel.URI.spec);
if (matches) {
_updateDBVersion('sync', matches[1]);
}
}
catch (e) {
Zotero.debug(e);
}
// Store the timestamp provided by the server // Store the timestamp provided by the server
_updateDBVersion('repository', currentTime); _updateDBVersion('repository', currentTime);
@ -793,9 +803,17 @@ Zotero.Schema = new function(){
} }
} }
var uri = xmlnode.getAttribute('id');
// Delete local style if CSL code is empty
if (!xmlnode.getElementsByTagName('csl')[0].firstChild) {
var sql = "DELETE FROM csl WHERE cslID=?";
Zotero.DB.query(sql, uri);
return true;
}
var sqlValues = [ var sqlValues = [
{string: xmlnode.getAttribute('id')}, {string: uri},
{string: xmlnode.getAttribute('updated')}, {string: xmlnode.getAttribute('updated')},
{string: xmlnode.getElementsByTagName('title')[0].firstChild.nodeValue}, {string: xmlnode.getElementsByTagName('title')[0].firstChild.nodeValue},
{string: xmlnode.getElementsByTagName('csl')[0].firstChild.nodeValue} {string: xmlnode.getElementsByTagName('csl')[0].firstChild.nodeValue}