From: phasefx Date: Fri, 6 Jun 2008 14:27:09 +0000 (+0000) Subject: Not sure why nsIFile.moveTo was breaking here, but replaced code with a copy of what... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=194b95411e4cfba4921798ef2c21e1d4a6ffe4b1;p=Evergreen.git Not sure why nsIFile.moveTo was breaking here, but replaced code with a copy of what the Upload action in the Offline Transaction Manageer was doing and that works git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2_2@9775 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/chrome/content/main/main.js b/Open-ILS/xul/staff_client/chrome/content/main/main.js index b17c2152b7..265f239c73 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/main.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/main.js @@ -147,15 +147,8 @@ function main_init() { 'Check here to confirm this message' ); if (r == 0) { - var count = 0; - var filename = 'pending_xacts_exported_' + new Date().getTime(); - var t_file = new util.file(filename); - while (t_file._file.exists()) { - filename = 'pending_xacts_' + new Date().getTime() + '.exported'; - t_file = new util.file(filename); - if (count++>100) throw('Error purging transactions: Taking too long to find a unique filename for archival.'); - } - file._file.moveTo(null,filename); + file.close(); + rename_file(); } else { alert('Please note that you now have two sets of identical transactions. Unless the set you just exported is soley for archival purposes, we run the risk of duplicate transactions being processed on the server.'); } @@ -331,4 +324,28 @@ function handle_migration() { } } +function rename_file() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + + try { + + JSAN.use('util.file'); + var pending = new util.file('pending_xacts'); + if ( !pending._file.exists() ) { throw("Can't rename a non-existent file"); } + var transition_filename = 'pending_xacts_' + new Date().getTime(); + var count = 0; + var file = new util.file(transition_filename); + while (file._file.exists()) { + transition_filename = 'pending_xacts_' + new Date().getTime(); + file = new util.file(transition_filename); + if (count++>100) throw("Taking too long to find a unique filename."); + } + pending._file.moveTo(null,transition_filename); + + } catch(E) { + alert('Error renaming xact file\n'+E); + } +} + + dump('exiting main/main.js\n');