/** * If direct write is disabled ,copies the stream contents to a temporary * file "<target>._COPYING_". If the copy is * successful, the temporary file will be renamed to the real path, * else the temporary file will be deleted. * if direct write is enabled , then creation temporary file is skipped. * @param in the input stream for the copy * @param target where to store the contents of the stream * @throws IOException if copy fails */ protected void copyStreamToTarget(InputStream in, PathData target) throws IOException { if (target.exists && (target.stat.isDirectory() || !overwrite)) { throw new PathExistsException(target.toString()); } TargetFileSystem targetFs = new TargetFileSystem(target.fs); try { PathData tempTarget = direct ? target : target.suffix("._COPYING_"); targetFs.setWriteChecksum(writeChecksum); targetFs.writeStreamToFile(in, tempTarget, lazyPersist, direct); if (!direct) { targetFs.rename(tempTarget, target); } } finally { targetFs.close(); // last ditch effort to ensure temp file is removed } }
/** * Copies the stream contents to a temporary file. If the copy is * successful, the temporary file will be renamed to the real path, * else the temporary file will be deleted. * @param in the input stream for the copy * @param target where to store the contents of the stream * @throws IOException if copy fails */ protected void copyStreamToTarget(InputStream in, PathData target) throws IOException { if (target.exists && (target.stat.isDirectory() || !overwrite)) { throw new PathExistsException(target.toString()); } TargetFileSystem targetFs = new TargetFileSystem(target.fs); try { PathData tempTarget = target.suffix("._COPYING_"); targetFs.setWriteChecksum(writeChecksum); targetFs.writeStreamToFile(in, tempTarget, lazyPersist); targetFs.rename(tempTarget, target); } finally { targetFs.close(); // last ditch effort to ensure temp file is removed } }
/** * Copies the stream contents to a temporary file. If the copy is * successful, the temporary file will be renamed to the real path, * else the temporary file will be deleted. * @param in the input stream for the copy * @param target where to store the contents of the stream * @throws IOException if copy fails */ protected void copyStreamToTarget(InputStream in, PathData target) throws IOException { if (target.exists && (target.stat.isDirectory() || !overwrite)) { throw new PathExistsException(target.toString()); } TargetFileSystem targetFs = new TargetFileSystem(target.fs); try { PathData tempTarget = target.suffix("._COPYING_"); targetFs.setWriteChecksum(writeChecksum); targetFs.writeStreamToFile(in, tempTarget, lazyPersist); targetFs.rename(tempTarget, target); } finally { targetFs.close(); // last ditch effort to ensure temp file is removed } }
/** * Copies the stream contents to a temporary file. If the copy is * successful, the temporary file will be renamed to the real path, * else the temporary file will be deleted. * @param in the input stream for the copy * @param target where to store the contents of the stream * @throws IOException if copy fails */ protected void copyStreamToTarget(InputStream in, PathData target) throws IOException { if (target.exists && (target.stat.isDirectory() || !overwrite)) { throw new PathExistsException(target.toString()); } TargetFileSystem targetFs = new TargetFileSystem(target.fs); try { PathData tempTarget = target.suffix("._COPYING_"); targetFs.setWriteChecksum(writeChecksum); targetFs.writeStreamToFile(in, tempTarget, lazyPersist); targetFs.rename(tempTarget, target); } finally { targetFs.close(); // last ditch effort to ensure temp file is removed } }
/** * If direct write is disabled ,copies the stream contents to a temporary * file "<target>._COPYING_". If the copy is * successful, the temporary file will be renamed to the real path, * else the temporary file will be deleted. * if direct write is enabled , then creation temporary file is skipped. * @param in the input stream for the copy * @param target where to store the contents of the stream * @throws IOException if copy fails */ protected void copyStreamToTarget(InputStream in, PathData target) throws IOException { if (target.exists && (target.stat.isDirectory() || !overwrite)) { throw new PathExistsException(target.toString()); } TargetFileSystem targetFs = new TargetFileSystem(target.fs); try { PathData tempTarget = direct ? target : target.suffix("._COPYING_"); targetFs.setWriteChecksum(writeChecksum); targetFs.writeStreamToFile(in, tempTarget, lazyPersist, direct); if (!direct) { targetFs.rename(tempTarget, target); } } finally { targetFs.close(); // last ditch effort to ensure temp file is removed } }