Skip to content

Commit

Permalink
Avoid state write if file download stats unchanged
Browse files Browse the repository at this point in the history
  • Loading branch information
parg committed Nov 26, 2024
1 parent 0be01b7 commit 6d8dc4b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions core/src/com/biglybt/core/disk/impl/DiskManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4074,22 +4074,27 @@ public void bytesDone(long num){
{
DownloadManagerState state = download_manager.getDownloadState();

Map details = new HashMap();
Map new_map = new HashMap();

List downloaded = new ArrayList();

details.put( "downloaded", downloaded );
new_map.put( "downloaded", downloaded );

for (int i=0;i<files.length;i++){

downloaded.add( new Long( files[i].getDownloaded()));
}

state.setMapAttribute( DownloadManagerState.AT_FILE_DOWNLOADED, details );
Map old_map = state.getMapAttribute( DownloadManagerState.AT_FILE_DOWNLOADED );

if ( persist ){

state.save( interim );
if ( !BEncoder.mapsAreIdentical(new_map, old_map)){

state.setMapAttribute( DownloadManagerState.AT_FILE_DOWNLOADED, new_map );

if ( persist ){

state.save( interim );
}
}
}

Expand Down

0 comments on commit 6d8dc4b

Please sign in to comment.