Skip to content

Commit

Permalink
add some log statements for download states, GitHub issue #145
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatinb committed Jun 10, 2022
1 parent 260fda5 commit a9bc2ec
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class NetworkDownloader extends Downloader {


protected void doCancel() {
log.info("CANCELLED:${getLogName()}")
stop()
synchronized(piecesFile) {
piecesFileClosed = true
Expand Down Expand Up @@ -359,6 +360,10 @@ class NetworkDownloader extends Downloader {
}
}
}

private String getLogName() {
file.getName() + ":" + Base64.encode(getInfoHash().getRoot())
}

class DownloadWorker implements Runnable {
private final Destination destination
Expand Down Expand Up @@ -460,7 +465,7 @@ class NetworkDownloader extends Downloader {
log.log(Level.WARNING, "Exception while downloading", DataUtil.findRoot(bad))
markFailed(destination)
if (!hasLiveSources() && hopelessEventFired.compareAndSet(false, true)) {
log.info("Download hopeless, removing incomplete file")
log.info("HOPELESS:${getLogName()}")
incompleteFile.delete()
closePiecesFile()
eventBus.publish(new DownloadHopelessEvent(downloader: NetworkDownloader.this))
Expand All @@ -472,6 +477,7 @@ class NetworkDownloader extends Downloader {
if (!this.cancelled) {
writePieces()
if (pieces.isComplete() && eventFired.compareAndSet(false, true)) {
log.info("COMPLETE:${getLogName()}")
closePiecesFile()

boolean confidential = NetworkDownloader.this.isConfidential()
Expand Down

0 comments on commit a9bc2ec

Please sign in to comment.