Feature #65822

Free space feedback from plugins to core

Added by raztoki about 4 years ago. Updated almost 4 years ago.

Status:ClosedStart date:05/30/2015
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:Controlling
Target version:020 - Next Release 2.0
Resolution:

Description

some plugins like youtube, mega require effectively 2 * the free space because
- youtube: downloads dash parts then mux together, then deletes dash parts after successful mux.
- mega: downloads encrypted component, which gets deleted after successful decrypt.

First approach

download selector evaluates if a given plugin requires x free space in order to start the download task.

create method like canHanle to evaluate downloadlinks free space needs.

boolean requiredFreeSpace(DownloadLink downloadLink) {
  // requires plugins to have semi valid filesize value set
  if (dl.isdash() && dowloadlink.getSize() > 0) {
    return doessavepathhavefreespacerequired(downloadLink, 2 * downloadLink.getSize())
  } else {
    return super;
  }
}

Second approach

make methods to call free space checker, so we can call from plugins. As in download finishes we recheck free space requirement before post download event to prevent failure. Since user could be downloading or extracting in JD or other programs the available free space no available to perform task when its going to fail!

booelan isSpaceFreeToPerformPostDownloadTask(DownloadLink downloadLink) { 
  // since we already have half the data ! we need ~approx another one half again (although decrypted component should be smaller than encrypted)
  return doessavepathhavefreespacerequired(downloadLink, downloadLink.getSize());
}
boolean doessavepathhavefreespacerequired(DownloadLink, long) {
  // determine save path
  return 'check path for free space value' > long;
}

conclusion

this is required to reduce over all IO and CPU cycles in events which cannot be performed successfully, which would then throw exception.

raztoki

Also available in: Atom PDF