Java Code Examples for com.facebook.common.file.FileUtils#CreateDirectoryException

The following examples show how to use com.facebook.common.file.FileUtils#CreateDirectoryException . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Checks if we have to recreate rootDirectory.
 * This is needed because old versions of this storage created too much different files
 * in the same dir, and Samsung's RFS has a bug that after the 13.000th creation fails.
 * So if cache is not already in expected version let's destroy everything
 * (if not in expected version... there's nothing to reuse here anyway).
 */
private void recreateDirectoryIfVersionChanges() {
  boolean recreateBase = false;
  if (!mRootDirectory.exists()) {
    recreateBase = true;
  } else if (!mVersionDirectory.exists()) {
    recreateBase = true;
    FileTree.deleteRecursively(mRootDirectory);
  }

  if (recreateBase) {
    try {
      FileUtils.mkdirs(mVersionDirectory);
    } catch (FileUtils.CreateDirectoryException e) {
      // not the end of the world, when saving files we will try to create missing parent dirs
      mCacheErrorLogger.logError(
          CacheErrorLogger.CacheErrorCategory.WRITE_CREATE_DIR,
          TAG,
          "version directory could not be created: " + mVersionDirectory,
          null);
    }
  }
}
 
Example 2
Source Project: fresco   File: DefaultDiskStorage.java    License: MIT License 6 votes vote down vote up
/**
 * Checks if we have to recreate rootDirectory. This is needed because old versions of this
 * storage created too much different files in the same dir, and Samsung's RFS has a bug that
 * after the 13.000th creation fails. So if cache is not already in expected version let's destroy
 * everything (if not in expected version... there's nothing to reuse here anyway).
 */
private void recreateDirectoryIfVersionChanges() {
  boolean recreateBase = false;
  if (!mRootDirectory.exists()) {
    recreateBase = true;
  } else if (!mVersionDirectory.exists()) {
    recreateBase = true;
    FileTree.deleteRecursively(mRootDirectory);
  }

  if (recreateBase) {
    try {
      FileUtils.mkdirs(mVersionDirectory);
    } catch (FileUtils.CreateDirectoryException e) {
      // not the end of the world, when saving files we will try to create missing parent dirs
      mCacheErrorLogger.logError(
          CacheErrorLogger.CacheErrorCategory.WRITE_CREATE_DIR,
          TAG,
          "version directory could not be created: " + mVersionDirectory,
          null);
    }
  }
}
 
Example 3
/**
 * Creates the directory (and its parents, if necessary).
 * In case of an exception, log an error message with the relevant parameters
 * @param directory the directory to create
 * @param message message to use
 * @throws IOException
 */
private void mkdirs(File directory, String message) throws IOException {
  try {
    FileUtils.mkdirs(directory);
  } catch (FileUtils.CreateDirectoryException cde) {
    mCacheErrorLogger.logError(
        CacheErrorLogger.CacheErrorCategory.WRITE_CREATE_DIR,
        TAG,
        message,
        cde);
    throw cde;
  }
}
 
Example 4
@VisibleForTesting
void createRootDirectoryIfNecessary(File rootDirectory) throws IOException {
  try {
    FileUtils.mkdirs(rootDirectory);
  } catch (FileUtils.CreateDirectoryException cde) {
    mCacheErrorLogger.logError(
        CacheErrorLogger.CacheErrorCategory.WRITE_CREATE_DIR,
        TAG,
        "createRootDirectoryIfNecessary",
        cde);
    throw cde;
  }
  FLog.d(TAG, "Created cache directory %s", rootDirectory.getAbsolutePath());
}
 
Example 5
Source Project: fresco   File: DynamicDefaultDiskStorage.java    License: MIT License 5 votes vote down vote up
@VisibleForTesting
void createRootDirectoryIfNecessary(File rootDirectory) throws IOException {
  try {
    FileUtils.mkdirs(rootDirectory);
  } catch (FileUtils.CreateDirectoryException cde) {
    mCacheErrorLogger.logError(
        CacheErrorLogger.CacheErrorCategory.WRITE_CREATE_DIR,
        TAG,
        "createRootDirectoryIfNecessary",
        cde);
    throw cde;
  }
  FLog.d(TAG, "Created cache directory %s", rootDirectory.getAbsolutePath());
}
 
Example 6
Source Project: fresco   File: DefaultDiskStorage.java    License: MIT License 5 votes vote down vote up
/**
 * Creates the directory (and its parents, if necessary). In case of an exception, log an error
 * message with the relevant parameters
 *
 * @param directory the directory to create
 * @param message message to use
 * @throws IOException
 */
private void mkdirs(File directory, String message) throws IOException {
  try {
    FileUtils.mkdirs(directory);
  } catch (FileUtils.CreateDirectoryException cde) {
    mCacheErrorLogger.logError(
        CacheErrorLogger.CacheErrorCategory.WRITE_CREATE_DIR, TAG, message, cde);
    throw cde;
  }
}