boolean backupOrg = true; long orgAge = System.currentTimeMillis() - orgFile.lastModified(); if ((orgAge >= 0) && (orgAge < agingInterval)) { backupOrg = false; }  if (newExists) {  rm(newFile); }  mv(tmpFile, newFile);  if (orgExists) { if (newExists) { rm(orgFile); } else { if (backupOrg) { rm(oldFile); mv(orgFile, oldFile); } else {  rm(orgFile); } } }  mv(newFile, orgFile); } finally { unlock();  release(); }
mv(outputFile, newFile); outputFile = null; appendChecksum = null; CacheInfo info = new CacheInfo(FILETYPE_VALID, checksum, newFile.lastModified()); cacheFiles.put(newFile, info); cleanup(generations, true); lastGenerationFile = null; lastGenerations = null;
	synchronized void closeOutputFile() throws IOException {		try {			boolean orgExists = orgFile.exists();			boolean newExists = newFile.exists();			// fix for files being cached too often. On some platforms (seen on Windows XP & QNX),			//  the data just written to a file can held in the filesystem cache. If the file is			//  written to too often, then both the orgFile and oldFile data contents can be held			//  in cache. The problem is that the directory structure can be flushed before the 			//  data is flushed (easily recreated on Windows XP) then if power is lost then both the 			//  orgFile and oldFile contents are garbage. To reduce the chances of this, we will			//  only move an orgFile to oldFile if it is older than N seconds. This will greatly 			//  reduce the chances that both copies could be lost in the filesystem cache during a 			//  power off/failure. The net result is, when a file is written several times in a short			//  time frame, we will move the original orgFile to oldFile, then rewrite orgFile several times			//  without changing oldFile. - PAL			// This problem is greatly reduced by calling java.io.FileOutputStream.getFD().sync() method			//  before the close. Now this time can be shortened considerably. -PAL			boolean backupOrg = true;			long orgAge = System.currentTimeMillis() - orgFile.lastModified();			if ((orgAge >= 0) && (orgAge < agingInterval)) {				backupOrg = false;			}			if (newExists) {				// shouldn't be possible, but just in case - PAL				rm(newFile);			}			mv(tmpFile, newFile);			if (orgExists) {				if (newExists) {					rm(orgFile);				} else {					if (backupOrg) {						rm(oldFile);						mv(orgFile, oldFile);					} else {						// orgFile is not old enough, do not replace oldFile.						rm(orgFile);					}				}			}			mv(newFile, orgFile);		} finally {			unlock();			release();		}	}