Example #1
0
 private static void recursiveRemoveOwnership(DirectoryHandle dir, long lastModified) {
   try {
     dir.setUsername("drftpd");
     dir.setGroup("drftpd");
     dir.setLastModified(lastModified);
     for (InodeHandle file : dir.getInodeHandlesUnchecked()) {
       file.setUsername("drftpd");
       file.setGroup("drftpd");
       file.setLastModified(lastModified);
       if (file.isDirectory()) recursiveRemoveOwnership((DirectoryHandle) file, lastModified);
     }
   } catch (FileNotFoundException e) {
     logger.warn("FileNotFoundException on recursiveRemoveOwnership()", e);
   }
 }
Example #2
0
  private void preAwardCredits(DirectoryHandle preDir, HashMap<User, Long> awards) {
    try {
      for (InodeHandle file : preDir.getInodeHandlesUnchecked()) {
        if (file.isFile()) {
          User owner;

          try {
            owner =
                GlobalContext.getGlobalContext()
                    .getUserManager()
                    .getUserByNameUnchecked(file.getUsername());
          } catch (NoSuchUserException e) {
            logger.warn("PRE: Cannot award credits to non-existing user", e);
            continue;
          } catch (UserFileException e) {
            logger.warn("", e);
            continue;
          } catch (FileNotFoundException e) {
            logger.warn("", e);
            continue;
          }

          Long total = awards.get(owner);
          if (total == null) {
            total = 0L;
          }
          total =
              (total
                  + (long)
                      (file.getSize() * owner.getKeyedMap().getObjectFloat(UserManagement.RATIO)));
          awards.put(owner, total);
        }

        if (file.isDirectory()) {
          preAwardCredits((DirectoryHandle) file, awards);
        }
      }
    } catch (FileNotFoundException e) {
      logger.warn("FileNotFoundException on preAwardCredits()", e);
    }
  }