/** * Creates a temporary file, either using the config (if initialized) or * using the global temporary directory. */ protected File createTempFile(String name) throws IOException { if (config == null) { return File.createTempFile(String.format("temp-%s-", name), ".tmp"); } else { return config.getCache().createTempFile(name); } }
/** * Creates a temporary file, either using the config (if initialized) or * using the global temporary directory. */ protected File createTempFile(String name) throws IOException { // TODO [low] duplicate code with AbstractTransferManager if (config == null) { return File.createTempFile(String.format("temp-%s-", name), ".tmp"); } else { return config.getCache().createTempFile(name); } } }
/** * This method serializes the transaction to a local temporary file. */ private File writeLocalTransactionFile() throws StorageException { try { File localTransactionFile = config.getCache().createTempFile("transaction"); writeToFile(config.getTransformer(), localTransactionFile); return localTransactionFile; } catch (Exception e) { throw new StorageException("Could not create temporary file for transaction", e); } }
/** * This method checks what the current cleanup number is, increments it by one and adds * a new cleanup file to the transaction, to signify to other clients that Cleanup has occurred. */ private void updateCleanupFileInTransaction() throws StorageException, IOException { if (remoteTransaction.isEmpty()) { // No need to bump numbers return; } // Find all existing cleanup files Map<String, CleanupRemoteFile> cleanupFiles = transferManager.list(CleanupRemoteFile.class); long lastRemoteCleanupNumber = getLastRemoteCleanupNumber(cleanupFiles); // Schedule any existing cleanup files for deletion for (CleanupRemoteFile cleanupRemoteFile : cleanupFiles.values()) { remoteTransaction.delete(cleanupRemoteFile); } // Upload a new cleanup file that indicates changes File newCleanupFile = config.getCache().createTempFile("cleanup"); long newCleanupNumber = lastRemoteCleanupNumber + 1; remoteTransaction.upload(newCleanupFile, new CleanupRemoteFile(newCleanupNumber)); localDatabase.writeCleanupNumber(newCleanupNumber); }
File reconstructedFileInCache = config.getCache().createTempFile("reconstructedFileVersion"); logger.log(Level.INFO, " - Creating file " + fileVersion.getPath() + " to " + reconstructedFileInCache + " ...");