[open-ils-commits] r9775 - branches/rel_1_2_2/Open-ILS/xul/staff_client/chrome/content/main

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jun 6 10:27:11 EDT 2008


Author: phasefx
Date: 2008-06-06 10:27:09 -0400 (Fri, 06 Jun 2008)
New Revision: 9775

Modified:
   branches/rel_1_2_2/Open-ILS/xul/staff_client/chrome/content/main/main.js
Log:
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

Modified: branches/rel_1_2_2/Open-ILS/xul/staff_client/chrome/content/main/main.js
===================================================================
--- branches/rel_1_2_2/Open-ILS/xul/staff_client/chrome/content/main/main.js	2008-06-06 05:28:00 UTC (rev 9774)
+++ branches/rel_1_2_2/Open-ILS/xul/staff_client/chrome/content/main/main.js	2008-06-06 14:27:09 UTC (rev 9775)
@@ -147,15 +147,8 @@
 							'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 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');



More information about the open-ils-commits mailing list