Example #1
0
 /**
  * Called when the PeerCoordinator got the MetaInfo via magnet. CoordinatorListener. Create the
  * storage, tell SnarkManager, and give the storage back to the coordinator.
  *
  * @throws RuntimeException via fatal()
  * @since 0.8.4
  */
 public void gotMetaInfo(PeerCoordinator coordinator, MetaInfo metainfo) {
   try {
     String base = Storage.filterName(metainfo.getName());
     File baseFile;
     if (_util.getFilesPublic()) baseFile = new File(rootDataDir, base);
     else baseFile = new SecureFile(rootDataDir, base);
     // The following two may throw IOE...
     storage = new Storage(_util, baseFile, metainfo, this, false);
     storage.check();
     // ... so don't set meta until here
     meta = metainfo;
     if (completeListener != null) {
       String newName = completeListener.gotMetaInfo(this);
       if (newName != null) torrent = newName;
       // else some horrible problem
     }
     coordinator.setStorage(storage);
   } catch (IOException ioe) {
     if (storage != null) {
       try {
         storage.close();
       } catch (IOException ioee) {
       }
     }
     fatal("Could not check or create storage", ioe);
   }
 }