Esempio n. 1
0
  /**
   * kills all in-network downloaders whose URNs are not listed in the list of updates. Deletes any
   * files in the folder that are not listed in the update message.
   */
  private void killObsoleteUpdates(List<? extends DownloadInformation> toDownload) {
    if (!downloadManager.get().isSavedDownloadsLoaded()
        || !fileManager.get().getManagedFileList().isLoadFinished()) return;

    if (_killingObsoleteNecessary) {
      _killingObsoleteNecessary = false;
      downloadManager.get().killDownloadersNotListed(toDownload);

      Set<URN> urns = new HashSet<URN>(toDownload.size());
      for (DownloadInformation data : toDownload) urns.add(data.getUpdateURN());

      List<FileDesc> shared =
          fileManager
              .get()
              .getGnutellaFileList()
              .getFilesInDirectory(LibraryUtils.PREFERENCE_SHARE);
      for (FileDesc fd : shared) {
        if (fd.getSHA1Urn() != null && !urns.contains(fd.getSHA1Urn())) {
          fileManager.get().getManagedFileList().remove(fd.getFile());
          fd.getFile().delete();
        }
      }
    }
  }
Esempio n. 2
0
 public URN getSHA1Urn() {
   return fileDesc.getSHA1Urn();
 }