Ejemplo n.º 1
0
  public static final void main(String[] args) throws Exception {
    LogManager.getLogManager().readConfiguration(new FileInputStream("./logging.properties"));
    UpdatingFileTree tree =
        new UpdatingFileTree(
            new File("/Volumes/x/watch_test"),
            new UpdatingFileTreeListener() {
              public void broadcastChange(UpdatingFileTree path, boolean isDelete) {
                System.out.println("change: " + path.getThisFile().getName() + " " + isDelete);
              }
            });

    while (true) {
      tree.update();
      Thread.sleep(5 * 1000);
    }
  }
Ejemplo n.º 2
0
 public static String bind_audio_scan() {
   long start = System.currentTimeMillis();
   StringBuilder out = new StringBuilder();
   out.append("bind audio scan...");
   String metainfoPath = SystemProperties.getMetaInfoPath();
   UpdatingFileTree metainfo = new UpdatingFileTree(new File(metainfoPath));
   List<UpdatingFileTree> q = new ArrayList<UpdatingFileTree>();
   q.add(metainfo);
   while (q.isEmpty() == false) {
     UpdatingFileTree curr = q.remove(0);
     if (curr.isDirectory()) {
       q.addAll(curr.getChildren());
     } else if (curr.getThisFile().getName().equals(PreviewImageGenerator.AUDIO_INFO_FILE)) {
       String hashStr = curr.getThisFile().getParentFile().getName();
       byte[] hashBytes = Base32.decode(hashStr);
       DownloadManager dm =
           AzureusCoreImpl.getSingleton()
               .getGlobalManager()
               .getDownloadManager(new HashWrapper(hashBytes));
       // old metainfo and/or bogus directory name
       if (dm == null) {
         continue;
       }
       logger.finest("rebind audio considering: " + dm.getDisplayName());
       out.append("considered: " + dm.getDisplayName());
       if (dm.getDownloadState().getAttribute(FileCollection.ONESWARM_ARTIST_ATTRIBUTE) == null
           && dm.getDownloadState().getAttribute(FileCollection.ONESWARM_ALBUM_ATTRIBUTE)
               == null) {
         logger.finer("should rebind audio " + dm.getDisplayName());
         out.append("rebinding for: " + dm.getDisplayName());
         bind_audio_xml(dm);
       }
     }
   }
   String str = "binding audio scan took: " + (System.currentTimeMillis() - start);
   logger.info(str);
   out.append(str);
   return out.toString();
 }