示例#1
0
 //// cleanupCache
 private void cleanupCache(NntpArticleHeader header) {
   log.debug("cleaning up cache files");
   try {
     NntpArticlePartID[] ids = header.getParts();
     if ((ids != null) && (ids.length > 0)) {
       for (int x = 0; x < ids.length; x++) {
         try {
           NntpArticlePartID currentPart = ids[x];
           File cachefile =
               new File(
                   cacheDir
                       + File.separator
                       + header.getServer()
                       + "."
                       + header.getGroup()
                       + "."
                       + currentPart.getIdAsString());
           if (cachefile.exists()) {
             log.debug("is writable: " + cachefile.canWrite());
             if (!cachefile.delete()) {
               log.warn("failed removing cachefile: " + cachefile.toString());
             }
           }
         } catch (SecurityException se) {
           log.warn("caught exception removing cachefile: " + se.getMessage());
         }
       }
     } else {
       try {
         File cachefile =
             new File(
                 cacheDir
                     + File.separator
                     + header.getServer()
                     + "."
                     + header.getGroup()
                     + "."
                     + header.getID());
         if (cachefile.exists()) {
           log.debug("is writable: " + cachefile.canWrite());
           if (!cachefile.delete()) {
             log.warn("failed removing cachefile: " + cachefile.toString());
           }
         }
       } catch (SecurityException se) {
         log.warn("caught exception removing cachefile: " + se.getMessage());
       }
     }
   } catch (NullPointerException npe) {
     log.error("what happened, null pointer exception: " + npe.getMessage());
   }
 }
示例#2
0
 private File getCacheFile(NntpArticleHeader header, NntpArticlePartID part) {
   File file =
       new File(
           cacheDir
               + File.separator
               + header.getServer()
               + "."
               + header.getGroup()
               + "."
               + part.getIdAsString());
   return file;
 }