Search in sources :

Example 1 with DownloadManagerStatsImpl

use of com.biglybt.core.download.impl.DownloadManagerStatsImpl in project BiglyBT by BiglySoftware.

the class DiskManagerImpl method fixupSkippedCalculation.

private void fixupSkippedCalculation() {
    if (skipped_file_set_changed) {
        DiskManagerFileInfoImpl[] current_files = files;
        if (current_files != null) {
            skipped_file_set_changed = false;
            try {
                file_piece_mon.enter();
                long skipped = 0;
                long downloaded = 0;
                for (int i = 0; i < current_files.length; i++) {
                    DiskManagerFileInfoImpl file = current_files[i];
                    if (file.isSkipped()) {
                        skipped += file.getLength();
                        downloaded += file.getDownloaded();
                    }
                }
                skipped_file_set_size = skipped;
                skipped_but_downloaded = downloaded;
            } finally {
                file_piece_mon.exit();
            }
            DownloadManagerStats stats = download_manager.getStats();
            if (stats instanceof DownloadManagerStatsImpl) {
                ((DownloadManagerStatsImpl) stats).setSkippedFileStats(skipped_file_set_size, skipped_but_downloaded);
            }
        }
    }
}
Also used : DownloadManagerStatsImpl(com.biglybt.core.download.impl.DownloadManagerStatsImpl) DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats)

Example 2 with DownloadManagerStatsImpl

use of com.biglybt.core.download.impl.DownloadManagerStatsImpl in project BiglyBT by BiglySoftware.

the class DiskManagerUtil method storeFilePriorities.

protected static void storeFilePriorities(DownloadManager download_manager, DiskManagerFileInfo[] files) {
    if (files == null)
        return;
    // bit confusing this: priorities are stored as
    // >= 1   : priority, 1 = high, 2 = higher etc
    // 0      : skipped
    // -1     : normal priority
    // <= -2  : negative priority , so -2 -> priority -1, -3 -> priority -2 etc
    List file_priorities = new ArrayList(files.length);
    for (int i = 0; i < files.length; i++) {
        DiskManagerFileInfo file = files[i];
        if (file == null)
            return;
        boolean skipped = file.isSkipped();
        int priority = file.getPriority();
        int value;
        if (skipped) {
            value = 0;
        } else if (priority > 0) {
            value = priority;
        } else {
            value = priority - 1;
            if (value > 0) {
                value = Integer.MIN_VALUE;
            }
        }
        file_priorities.add(i, Long.valueOf(value));
    }
    download_manager.setUserData("file_priorities", file_priorities);
    if (files.length > 0 && !(files[0] instanceof DiskManagerFileInfoImpl)) {
        long skipped_file_set_size = 0;
        long skipped_but_downloaded = 0;
        for (int i = 0; i < files.length; i++) {
            DiskManagerFileInfo file = files[i];
            if (file.isSkipped()) {
                skipped_file_set_size += file.getLength();
                skipped_but_downloaded += file.getDownloaded();
            }
        }
        DownloadManagerStats stats = download_manager.getStats();
        if (stats instanceof DownloadManagerStatsImpl) {
            ((DownloadManagerStatsImpl) stats).setSkippedFileStats(skipped_file_set_size, skipped_but_downloaded);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) DownloadManagerStatsImpl(com.biglybt.core.download.impl.DownloadManagerStatsImpl) ArrayList(java.util.ArrayList) List(java.util.List) DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats)

Aggregations

DownloadManagerStats (com.biglybt.core.download.DownloadManagerStats)2 DownloadManagerStatsImpl (com.biglybt.core.download.impl.DownloadManagerStatsImpl)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1