Examples of DownloadManagerState


Examples of org.gudy.azureus2.core3.download.DownloadManagerState

         
          String[] types = DiskManagerImpl.getStorageTypes(download_manager);
          boolean[] modified = new boolean[res.length];
          boolean[] toSkip = new boolean[res.length];
          int toSkipCount = 0;
          DownloadManagerState dmState = download_manager.getDownloadState();
         
          try {
            dmState.suppressStateSave(true);
 
            for(int i=0;i<res.length;i++)
            {
              if(!toChange[i])
                continue;
 
 
              final int idx = i;
 
              int old_type = DiskManagerUtil.convertDMStorageTypeFromString( types[i] );
 
              //System.out.println(old_type + " <> " + newStroageType);
 
              if ( newStorageType == old_type )
              {
                modified[i] = true;
                continue;
              }
 
              try{
                File    target_file = res[i].getFile( true );
 
                // if the file doesn't exist then this is the start-of-day, most likely
                // being called from the torrent-opener, so we don't need to do any
                // file fiddling (in fact, if we do, we end up leaving zero length
                // files for dnd files which then force a recheck when the download
                // starts for the first time)
 
                if ( target_file.exists()){
 
                  CacheFile cache_file =
                    CacheFileManagerFactory.getSingleton().createFile(
                      new CacheFileOwner()
                      {
                        public String
                        getCacheFileOwnerName()
                        {
                          return( download_manager.getInternalName());
                        }
 
                        public TOTorrentFile
                        getCacheFileTorrentFile()
                        {
                          return( res[idx].getTorrentFile() );
                        }
 
                        public File
                        getCacheFileControlFileDir()
                        {
                          return( download_manager.getDownloadState().getStateFile( ));
                        }
                        public int
                        getCacheMode()
                        {
                          return( CacheFileOwner.CACHE_MODE_NORMAL );
                        }
                      },
                      target_file,
                      DiskManagerUtil.convertDMStorageTypeToCache( newStorageType ));
 
                  cache_file.close();
 
                  toSkip[i] = ( newStorageType == FileSkeleton.ST_COMPACT || newStorageType == FileSkeleton.ST_REORDER_COMPACT )&& !res[i].isSkipped();
                  if(toSkip[i])
                    toSkipCount++;
                }
 
 
                modified[i] = true;
 
              }catch( Throwable e ){
 
                Debug.printStackTrace(e);
 
                Logger.log(
                  new LogAlert(download_manager,
                    LogAlert.REPEATABLE,
                    LogAlert.AT_ERROR,
                    "Failed to change storage type for '" + res[i].getFile(true) +"': " + Debug.getNestedExceptionMessage(e)));
 
                // download's not running - tag for recheck
 
                RDResumeHandler.recheckFile( download_manager, res[i] );
 
              }
 
              types[i] = DiskManagerUtil.convertDMStorageTypeToString( newStorageType );
            }
           
            /*
             * set storage type and skipped before we do piece clearing and file
             * clearing checks as those checks work better when skipped/stype is set
             * properly
             */
            dmState.setListAttribute( DownloadManagerState.AT_FILE_STORE_TYPES, types);
            if(toSkipCount > 0)
              setSkipped(toSkip, true);
           
           
            for(int i=0;i<res.length;i++)
            {
              if(!toChange[i])
                continue;
             
              // download's not running, update resume data as necessary
 
              int cleared = RDResumeHandler.storageTypeChanged( download_manager, res[i] );
 
              // try and maintain reasonable figures for downloaded. Note that because
              // we don't screw with the first and last pieces of the file during
              // storage type changes we don't have the problem of dealing with
              // the last piece being smaller than torrent piece size
 
              if (cleared > 0)
              {
                res[i].downloaded = res[i].downloaded - cleared * res[i].getTorrentFile().getTorrent().getPieceLength();
                if (res[i].downloaded < 0) res[i].downloaded = 0;
              }
            }
 
            DiskManagerImpl.storeFileDownloaded( download_manager, res, true );
 
            doFileExistenceChecks(this, toChange, download_manager, newStorageType == FileSkeleton.ST_LINEAR || newStorageType == FileSkeleton.ST_REORDER );
 
          } finally {
            dmState.suppressStateSave(false);
            dmState.save();
          }
         
          return modified;
        }
          };
View Full Code Here

Examples of org.gudy.azureus2.core3.download.DownloadManagerState

  protected static void
    loadFileDownloaded(
      DownloadManager             download_manager,
      DiskManagerFileInfoHelper[] files )
    {
        DownloadManagerState  state = download_manager.getDownloadState();
 
        Map   details = state.getMapAttribute( DownloadManagerState.AT_FILE_DOWNLOADED );
 
        if ( details == null ){
 
            return;
        }
View Full Code Here

Examples of org.gudy.azureus2.core3.download.DownloadManagerState

      if ( TorrentUtils.isDecentralised(to_torrent)){
       
        TorrentUtils.setDecentralised( to_torrent );
      }
           
      DownloadManagerState  download_manager_state =
        DownloadManagerStateFactory.getDownloadState( to_torrent );

      TorrentUtils.setResumeDataCompletelyValid( download_manager_state );

      download_manager_state.save();
     
      if ( item == null ){
       
        byte[] fingerprint = getFingerPrint();
     
View Full Code Here

Examples of org.gudy.azureus2.core3.download.DownloadManagerState

    throws TorrentException
  {   
    try{
      LocaleTorrentUtil.setDefaultTorrentEncoding( torrent );
   
      DownloadManagerState  download_manager_state =
        DownloadManagerStateFactory.getDownloadState( torrent );

      TorrentUtils.setResumeDataCompletelyValid( download_manager_state );

      download_manager_state.save();
     
      complete  = true;
     
    }catch( Throwable e ){
     
View Full Code Here

Examples of org.gudy.azureus2.core3.download.DownloadManagerState

    return diskManager;
  }
 
  public DownloadManager  getDownloadManager()
  {
    DownloadManagerState  state = diskManager.getDownloadState();
   
    if ( state == null ){
      return( null );
    }
   
    return( state.getDownloadManager());
  }
View Full Code Here

Examples of org.gudy.azureus2.core3.download.DownloadManagerState

  public void setPriority(int[] toChange) {
    if(toChange.length != files.length)
      throw new IllegalArgumentException("array length mismatches the number of files");

    DownloadManagerState dmState = diskManager.getDownloadState();
   
    try  {
      dmState.suppressStateSave(true);

   
      for(int i=0;i<files.length;i++)
        if(toChange[i] > 0)
          files[i].setPriority(toChange[i]);
    } finally {
      dmState.suppressStateSave(false);
    }
  }
View Full Code Here

Examples of org.gudy.azureus2.core3.download.DownloadManagerState

  public void setSkipped(boolean[] toChange, boolean setSkipped) {
    if(toChange.length != files.length)
      throw new IllegalArgumentException("array length mismatches the number of files");

    DownloadManagerState dmState = diskManager.getDownloadState();
   
    try  {
      dmState.suppressStateSave(true);
     
      if (!setSkipped ){
       
        String[] types = diskManager.getStorageTypes();

        boolean[]  toLinear   = new boolean[toChange.length];
        boolean[]  toReorder   = new boolean[toChange.length];
       
        int  num_linear   = 0;
        int num_reorder  = 0;
       
        for ( int i=0;i<toChange.length;i++){
         
          if ( toChange[i] ){
           
            int old_type = DiskManagerUtil.convertDMStorageTypeFromString( types[i] );
           
            if ( old_type == DiskManagerFileInfo.ST_COMPACT ){
             
              toLinear[i] = true;
             
              num_linear++;
             
            }else if ( old_type == DiskManagerFileInfo.ST_REORDER_COMPACT ){
             
              toReorder[i] = true;
             
              num_reorder++;
            }
          } 
        }
       
        if ( num_linear > 0 ){
         
          if (!Arrays.equals(toLinear, setStorageTypes(toLinear, DiskManagerFileInfo.ST_LINEAR))){
           
            return;
          }
        }
     
        if ( num_reorder > 0 ){
         
          if (!Arrays.equals(toReorder, setStorageTypes(toReorder, DiskManagerFileInfo.ST_REORDER ))){
           
            return;
          }
        }
      }
      for (int i = 0; i < files.length; i++)
        if (toChange[i])
        {
          files[i].skipped = setSkipped;
          diskManager.skippedFileSetChanged(files[i]);
        }

      if(!setSkipped)
        DiskManagerUtil.doFileExistenceChecks(this, toChange, diskManager.getDownloadState().getDownloadManager(), true);
     
    } finally {
      dmState.suppressStateSave(false);
    }

  }
View Full Code Here

Examples of org.gudy.azureus2.core3.download.DownloadManagerState

      return new boolean[0];
   
    String[] types = diskManager.getStorageTypes();
   
    boolean[] modified = new boolean[files.length];
    DownloadManagerState  dm_state = diskManager.getDownloadState();

    if (newStroageType == DiskManagerFileInfo.ST_COMPACT || newStroageType == DiskManagerFileInfo.ST_REORDER_COMPACT)
    {
      Debug.out("Download must be stopped for linear -> compact conversion");
      return modified;
    }
   
    try  {
      dm_state.suppressStateSave(true);

      for (int i = 0; i < files.length; i++)
      {
        if(!toChange[i])
          continue;
       
        int old_type = DiskManagerUtil.convertDMStorageTypeFromString( types[i] );
        if (newStroageType == old_type)
        {
          modified[i] = true;
          continue;
        }
     
        DiskManagerFileInfoImpl file = files[i];
       
        try  {
          file.getCacheFile().setStorageType( DiskManagerUtil.convertDMStorageTypeToCache( newStroageType ));
          modified[i] = true;
        } catch (Throwable e) {
          Debug.printStackTrace(e);
          diskManager.setFailed(file, "Failed to change storage type for '" + file.getFile(true) + "': " + Debug.getNestedExceptionMessage(e));
          break;
        } finally {
          types[i] = DiskManagerUtil.convertCacheStorageTypeToString( file.getCacheFile().getStorageType());
        }
      }
     
      dm_state.setListAttribute(DownloadManagerState.AT_FILE_STORE_TYPES, types);
     
      DiskManagerUtil.doFileExistenceChecks(this, toChange, dm_state.getDownloadManager(), true);
     
    } finally {
      dm_state.suppressStateSave(false);
      dm_state.save();
    }
   
    return modified;
  }
View Full Code Here

Examples of org.gudy.azureus2.core3.download.DownloadManagerState

         
          TOTorrent to_torrent = PluginCoreUtils.unwrap( torrent );
         
          if ( public_net && !TorrentUtils.isReallyPrivate( to_torrent )){
           
            DownloadManagerState state = PluginCoreUtils.unwrap( download ).getDownloadState();

            if ( state.getFlag(DownloadManagerState.FLAG_LOW_NOISE )){
             
              continue;
            }
           
            long rand = global_random_id ^ state.getLongParameter( DownloadManagerState.PARAM_RANDOM_SEED );           
           
            long cache = state.getLongAttribute( DownloadManagerState.AT_SCRAPE_CACHE );

            int  seeds_leechers;
           
            if ( cache == -1 ){
             
View Full Code Here

Examples of org.gudy.azureus2.core3.download.DownloadManagerState

    for (final DownloadManager dm : dms) {
      if (dm == null) {
        continue;
      }

      DownloadManagerState dmState = dm.getDownloadState();

      final TOTorrent torrent = dm.getTorrent();
      if (torrent == null) {
        continue;
      }

      String title = PlatformTorrentUtils.getContentTitle(torrent);
      if (title != null && title.length() > 0
          && dmState.getDisplayName() == null) {
        dmState.setDisplayName(title);
      }

      if (ConfigurationChecker.isNewVersion() && dm.getAssumedComplete()) {
        String lastVersion = COConfigurationManager.getStringParameter("Last Version");
        if (org.gudy.azureus2.core3.util.Constants.compareVersions(lastVersion,
            "3.1.1.1") <= 0) {
          long completedTime = dmState.getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_COMPLETED_TIME);
          if (completedTime < SystemTime.getOffsetTime(-(1000 * 60))) {
            PlatformTorrentUtils.setHasBeenOpened(dm, true);
          }
        }
      }

      boolean isContent = PlatformTorrentUtils.isContent(torrent, true)
          || PlatformTorrentUtils.getContentNetworkID(torrent) == ContentNetwork.CONTENT_NETWORK_VHDNL;

      if (!oneIsNotPlatformAndPersistent && !isContent
          && !dmState.getFlag(DownloadManagerState.FLAG_LOW_NOISE) && dm.isPersistent()) {
        oneIsNotPlatformAndPersistent = true;
      }

      if (isContent) {
        long now = SystemTime.getCurrentTime();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.