- Timestamp:
- 02/04/19 10:54:41 (5 years ago)
- Location:
- trunk/src/org/expeditee/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/Frame.java
r1227 r1229 101 101 102 102 private String _modifiedDate = null; 103 private long _modifiedDatePrecise; 103 104 104 105 private String _frozenDate = null; … … 803 804 * @param date 804 805 * The date to set as the last modified date. 805 * /806 public void setLastModifyDate(String date)807 {806 * @param precise The millisecond precision last modified date. 807 */ 808 public void setLastModifyDate(String date, long precise) { 808 809 _modifiedDate = date; 810 _modifiedDatePrecise = precise; 811 } 812 813 /** 814 * Sets the last modified date of this Frame to the given String. 815 * Used during startup. If able to be more precise then use the overloaded function. 816 * 817 * @param date 818 * The date to set as the last modified date. 819 */ 820 public void setLastModifyDate(String date) { 821 _modifiedDate = date; 822 _modifiedDatePrecise = -1l; 809 823 } 810 824 … … 815 829 * The date to set as the last frozen date. 816 830 */ 817 public void setFrozenDate(String date) 818 { 831 public void setFrozenDate(String date) { 819 832 _frozenDate = date; 820 833 } … … 1198 1211 } 1199 1212 1200 public String getLastModifyDate() 1201 { 1213 public String getLastModifyDate() { 1202 1214 return _modifiedDate; 1215 } 1216 1217 public long getLastModifyPrecise() { 1218 return _modifiedDatePrecise; 1203 1219 } 1204 1220 -
trunk/src/org/expeditee/gui/FrameIO.java
r1227 r1229 220 220 Logger.Log(Logger.SYSTEM, Logger.LOAD, "Loading " + frameName + " from cache."); 221 221 Frame frame = _Cache.get(frameNameLower); 222 return frame; 222 223 // if frame is cache is older than the one on disk then don't use the cached one 224 String p = frame.getPath() + frame.getNumber() + ".exp"; 225 File file = new File(p); 226 if (file.lastModified() <= frame.getLastModifyPrecise()) { 227 return frame; 228 } 223 229 } 224 230 … … 230 236 231 237 //Loads the 'restore' version of a frame if there is one 232 238 public static Frame LoadRestoreFrame(Frame frameToRestore) { 233 239 234 String fullPath = getFrameFullPathName(frameToRestore.getPath(), frameToRestore 235 .getName()); 236 //System.out.println("fullpath: " + fullPath); 237 String restoreVersion = fullPath + ".restore"; 238 //System.out.println("restoreversion" + restoreVersion); 239 File source = new File(restoreVersion); 240 File dest = new File(fullPath); 241 242 FileChannel inputChannel = null; 243 FileChannel outputChannel = null; 244 245 try{ 246 FileInputStream source_fis = new FileInputStream(source); 247 inputChannel = source_fis.getChannel(); 248 249 FileOutputStream dest_fos = new FileOutputStream(dest); 250 outputChannel = dest_fos.getChannel(); 251 252 outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); 253 inputChannel.close(); 254 outputChannel.close(); 255 source_fis.close(); 256 dest_fos.close(); 257 } 258 catch(Exception e){ 240 String fullPath = getFrameFullPathName(frameToRestore.getPath(), frameToRestore 241 .getName()); 242 //System.out.println("fullpath: " + fullPath); 243 String restoreVersion = fullPath + ".restore"; 244 //System.out.println("restoreversion" + restoreVersion); 245 File source = new File(restoreVersion); 246 File dest = new File(fullPath); 247 248 FileChannel inputChannel = null; 249 FileChannel outputChannel = null; 250 251 try{ 252 FileInputStream source_fis = new FileInputStream(source); 253 inputChannel = source_fis.getChannel(); 259 254 260 System.err.println("No restore point detected."); 261 } 262 String frameName = frameToRestore.getName(); 263 String frameNameLower = frameName.toLowerCase(); 264 265 // first try reading from cache 266 if (isCacheOn() && _Cache.containsKey(frameNameLower)) { 267 Logger.Log(Logger.SYSTEM, Logger.LOAD, "Clearing " + frameName 268 + " from cache."); 269 _Cache.remove(frameNameLower); 270 } 271 272 return LoadFrame(frameName, frameToRestore.getPath(), true); 273 } 255 FileOutputStream dest_fos = new FileOutputStream(dest); 256 outputChannel = dest_fos.getChannel(); 257 258 outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); 259 inputChannel.close(); 260 outputChannel.close(); 261 source_fis.close(); 262 dest_fos.close(); 263 } 264 catch(Exception e){ 265 System.err.println("No restore point detected."); 266 } 267 String frameName = frameToRestore.getName(); 268 String frameNameLower = frameName.toLowerCase(); 269 270 // first try reading from cache 271 if (isCacheOn() && _Cache.containsKey(frameNameLower)) { 272 Logger.Log(Logger.SYSTEM, Logger.LOAD, "Clearing " + frameName 273 + " from cache."); 274 _Cache.remove(frameNameLower); 275 } 276 277 return LoadFrame(frameName, frameToRestore.getPath(), true); 278 } 274 279 275 280 public static BufferedReader LoadPublicFrame(String frameName) { … … 1809 1814 1810 1815 public static void setSavedProperties(Frame toSave) { 1811 toSave.setLastModifyDate(Formatter.getDateTime() );1816 toSave.setLastModifyDate(Formatter.getDateTime(), System.currentTimeMillis()); 1812 1817 toSave.setLastModifyUser(UserSettings.UserName.get()); 1813 1818 toSave.setVersion(toSave.getVersion() + 1);
Note:
See TracChangeset
for help on using the changeset viewer.