Search in sources :

Example 6 with FileExistsException

use of org.apache.commons.io.FileExistsException in project syncany by syncany.

the class FileSystemAction method moveToConflictFile.

protected void moveToConflictFile(NormalizedPath conflictingPath) throws IOException {
    if (!FileUtil.exists(conflictingPath.toFile())) {
        logger.log(Level.INFO, "     - Creation of conflict file not necessary. Locally conflicting file vanished from " + conflictingPath);
        return;
    }
    int attempts = 0;
    while (attempts++ < 10) {
        NormalizedPath conflictedCopyPath = null;
        try {
            conflictedCopyPath = findConflictFilename(conflictingPath);
            logger.log(Level.INFO, "     - Local version conflicts, moving local file " + conflictingPath + " to " + conflictedCopyPath + " ...");
            if (conflictingPath.toFile().isDirectory()) {
                FileUtils.moveDirectory(conflictingPath.toFile(), conflictedCopyPath.toFile());
            } else {
                FileUtils.moveFile(conflictingPath.toFile(), conflictedCopyPath.toFile());
            }
            // Success!
            break;
        } catch (FileExistsException e) {
            logger.log(Level.SEVERE, "     - Cannot create conflict file; attempt = " + attempts + " for file: " + conflictedCopyPath, e);
        } catch (FileNotFoundException e) {
            logger.log(Level.INFO, "     - Conflict file vanished. Don't care!", e);
        } catch (Exception e) {
            throw new RuntimeException("What to do here?", e);
        }
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) NormalizedPath(org.syncany.util.NormalizedPath) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) FileExistsException(org.apache.commons.io.FileExistsException) FileExistsException(org.apache.commons.io.FileExistsException)

Aggregations

FileExistsException (org.apache.commons.io.FileExistsException)6 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 NormalizedPath (org.syncany.util.NormalizedPath)2 BlobStore (com.alibaba.jstorm.blobstore.BlobStore)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStream (java.io.OutputStream)1 RandomAccessFile (java.io.RandomAccessFile)1 URL (java.net.URL)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 FinalizedReplica (org.apache.hadoop.hdfs.server.datanode.FinalizedReplica)1 FsVolumeReferences (org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi.FsVolumeReferences)1 MapJoinTableContainerSerDe (org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainerSerDe)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 BucketMapJoinContext (org.apache.hadoop.hive.ql.plan.BucketMapJoinContext)1