/** * Rename a file or folder. If the rename fails and if we are running on a * filesystem where it makes sense to repeat a failing rename then repeat * the rename operation up to 9 times with 100ms sleep time between two * calls. Furthermore if the destination exists and is directory hierarchy * with only directories in it, the whole directory hierarchy will be * deleted. If the target represents a non-empty directory structure, empty * subdirectories within that structure may or may not be deleted even if * the method fails. Furthermore if the destination exists and is a file * then the file will be deleted and then the rename is retried. * <p> * This operation is <em>not</em> atomic. * * @see FS#retryFailedLockFileCommit() * @param src * the old {@code File} * @param dst * the new {@code File} * @throws java.io.IOException * if the rename has failed * @since 3.0 */ public static void rename(File src, File dst) throws IOException { rename(src, dst, StandardCopyOption.REPLACE_EXISTING); }
private static boolean rename(File src, File dst) { try { FileUtils.rename(src, dst, StandardCopyOption.ATOMIC_MOVE); return true; } catch (AtomicMoveNotSupportedException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { // ignore } File dir = dst.getParentFile(); if ((dir.exists() || !dir.mkdirs()) && !dir.isDirectory()) return false; try { FileUtils.rename(src, dst, StandardCopyOption.ATOMIC_MOVE); return true; } catch (IOException e) { LOG.error(e.getMessage(), e); return false; } }
db.closeAllPackHandles(realPack); tmpPack.setReadOnly(); FileUtils.rename(tmpPack, realPack, ATOMIC_MOVE); FileUtils.rename(tmpIdx, realIdx, ATOMIC_MOVE); } catch (IOException e) { File newIdx = new File( realIdx.getParentFile(), realIdx.getName() + ".new"); //$NON-NLS-1$ try { FileUtils.rename(tmpIdx, newIdx, ATOMIC_MOVE); } catch (IOException e2) { newIdx = tmpIdx;
/** * Commit this change and release the lock. * <p> * If this method fails (returns false) the lock is still released. * * @return true if the commit was successful and the file contains the new * data; false if the commit failed and the file remains with the * old data. * @throws java.lang.IllegalStateException * the lock is not held. */ public boolean commit() { if (os != null) { unlock(); throw new IllegalStateException(MessageFormat.format(JGitText.get().lockOnNotClosed, ref)); } saveStatInformation(); try { FileUtils.rename(lck, ref, StandardCopyOption.ATOMIC_MOVE); haveLck = false; closeToken(); return true; } catch (IOException e) { unlock(); return false; } }
/** * Deletes old pack file, unless 'preserve-oldpacks' is set, in which case it * moves the pack file to the preserved directory * * @param packFile * @param packName * @param ext * @param deleteOptions * @throws IOException */ private void removeOldPack(File packFile, String packName, PackExt ext, int deleteOptions) throws IOException { if (pconfig != null && pconfig.isPreserveOldPacks()) { File oldPackDir = repo.getObjectDatabase().getPreservedDirectory(); FileUtils.mkdir(oldPackDir, true); String oldPackName = "pack-" + packName + ".old-" + ext.getExtension(); //$NON-NLS-1$ //$NON-NLS-2$ File oldPackFile = new File(oldPackDir, oldPackName); FileUtils.rename(packFile, oldPackFile); } else { FileUtils.delete(packFile, deleteOptions); } }
tmpPack.setReadOnly(); FileUtils.rename(tmpPack, realPack, StandardCopyOption.ATOMIC_MOVE); for (Map.Entry<PackExt, File> tmpEntry : tmpExts.entrySet()) { File tmpExt = tmpEntry.getValue(); "." + tmpEntry.getKey().getExtension()); //$NON-NLS-1$ try { FileUtils.rename(tmpExt, realExt, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) { realExt.getName() + ".new"); //$NON-NLS-1$ try { FileUtils.rename(tmpExt, newExt, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e2) {
/** * Rename a file or folder. If the rename fails and if we are running on a * filesystem where it makes sense to repeat a failing rename then repeat * the rename operation up to 9 times with 100ms sleep time between two * calls. Furthermore if the destination exists and is directory hierarchy * with only directories in it, the whole directory hierarchy will be * deleted. If the target represents a non-empty directory structure, empty * subdirectories within that structure may or may not be deleted even if * the method fails. Furthermore if the destination exists and is a file * then the file will be deleted and then the rename is retried. * <p> * This operation is <em>not</em> atomic. * * @see FS#retryFailedLockFileCommit() * @param src * the old {@code File} * @param dst * the new {@code File} * @throws java.io.IOException * if the rename has failed * @since 3.0 */ public static void rename(File src, File dst) throws IOException { rename(src, dst, StandardCopyOption.REPLACE_EXISTING); }
FileUtils.delete(f, FileUtils.RECURSIVE); FileUtils.rename(tmpFile, f, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) { throw new IOException(
FileUtils.rename(stashLockFile, stashFile, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) {
File dest = getFile(fh.getNewPath(), false); try { FileUtils.rename(f, dest, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) {
/** * Rename a file or folder. If the rename fails and if we are running on a * filesystem where it makes sense to repeat a failing rename then repeat * the rename operation up to 9 times with 100ms sleep time between two * calls. Furthermore if the destination exists and is directory hierarchy * with only directories in it, the whole directory hierarchy will be * deleted. If the target represents a non-empty directory structure, empty * subdirectories within that structure may or may not be deleted even if * the method fails. Furthermore if the destination exists and is a file * then the file will be deleted and then the rename is retried. * <p> * This operation is <em>not</em> atomic. * * @see FS#retryFailedLockFileCommit() * @param src * the old {@code File} * @param dst * the new {@code File} * @throws IOException * if the rename has failed * @since 3.0 */ public static void rename(final File src, final File dst) throws IOException { rename(src, dst, StandardCopyOption.REPLACE_EXISTING); }
private static boolean rename(File src, File dst) { try { FileUtils.rename(src, dst, StandardCopyOption.ATOMIC_MOVE); return true; } catch (AtomicMoveNotSupportedException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { // ignore } File dir = dst.getParentFile(); if ((dir.exists() || !dir.mkdirs()) && !dir.isDirectory()) return false; try { FileUtils.rename(src, dst, StandardCopyOption.ATOMIC_MOVE); return true; } catch (IOException e) { LOG.error(e.getMessage(), e); return false; } }
private static boolean rename(File src, File dst) { try { FileUtils.rename(src, dst, StandardCopyOption.ATOMIC_MOVE); return true; } catch (AtomicMoveNotSupportedException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { // ignore } File dir = dst.getParentFile(); if ((dir.exists() || !dir.mkdirs()) && !dir.isDirectory()) return false; try { FileUtils.rename(src, dst, StandardCopyOption.ATOMIC_MOVE); return true; } catch (IOException e) { LOG.error(e.getMessage(), e); return false; } }
/** * Commit this change and release the lock. * <p> * If this method fails (returns false) the lock is still released. * * @return true if the commit was successful and the file contains the new * data; false if the commit failed and the file remains with the * old data. * @throws IllegalStateException * the lock is not held. */ public boolean commit() { if (os != null) { unlock(); throw new IllegalStateException(MessageFormat.format(JGitText.get().lockOnNotClosed, ref)); } saveStatInformation(); try { FileUtils.rename(lck, ref, StandardCopyOption.ATOMIC_MOVE); haveLck = false; return true; } catch (IOException e) { unlock(); return false; } }
FileUtils.mkdirs(parent.toFile(), true); FileUtils.rename(tmpFile.toFile(), mediaFile.toFile(), StandardCopyOption.ATOMIC_MOVE);
db.closeAllPackHandles(realPack); tmpPack.setReadOnly(); FileUtils.rename(tmpPack, realPack, ATOMIC_MOVE); FileUtils.rename(tmpIdx, realIdx, ATOMIC_MOVE); } catch (IOException e) { File newIdx = new File( realIdx.getParentFile(), realIdx.getName() + ".new"); //$NON-NLS-1$ try { FileUtils.rename(tmpIdx, newIdx, ATOMIC_MOVE); } catch (IOException e2) { newIdx = tmpIdx;
/** * Commit this change and release the lock. * <p> * If this method fails (returns false) the lock is still released. * * @return true if the commit was successful and the file contains the new * data; false if the commit failed and the file remains with the * old data. * @throws java.lang.IllegalStateException * the lock is not held. */ public boolean commit() { if (os != null) { unlock(); throw new IllegalStateException(MessageFormat.format(JGitText.get().lockOnNotClosed, ref)); } saveStatInformation(); try { FileUtils.rename(lck, ref, StandardCopyOption.ATOMIC_MOVE); haveLck = false; closeToken(); return true; } catch (IOException e) { unlock(); return false; } }
/** * Deletes old pack file, unless 'preserve-oldpacks' is set, in which case it * moves the pack file to the preserved directory * * @param packFile * @param packName * @param ext * @param deleteOptions * @throws IOException */ private void removeOldPack(File packFile, String packName, PackExt ext, int deleteOptions) throws IOException { if (pconfig != null && pconfig.isPreserveOldPacks()) { File oldPackDir = repo.getObjectDatabase().getPreservedDirectory(); FileUtils.mkdir(oldPackDir, true); String oldPackName = "pack-" + packName + ".old-" + ext.getExtension(); //$NON-NLS-1$ //$NON-NLS-2$ File oldPackFile = new File(oldPackDir, oldPackName); FileUtils.rename(packFile, oldPackFile); } else { FileUtils.delete(packFile, deleteOptions); } }
File dest = getFile(fh.getNewPath(), false); try { FileUtils.rename(f, dest, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) {