Skip to content

Commit

Permalink
fix bug that seeder doesn't seed files after disconnecting all peers …
Browse files Browse the repository at this point in the history
…one time
  • Loading branch information
Dead-off committed Jan 16, 2019
1 parent cf2fae1 commit 1b6167c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public void removeTorrent(String torrentHash) {
SharedTorrent torrent = torrents.first();
if (torrent != null) {
torrent.setClientState(ClientState.DONE);
torrent.close();
torrent.closeFully();
}
List<SharingPeer> peers = getPeersForTorrent(torrentHash);
for (SharingPeer peer : peers) {
Expand Down Expand Up @@ -474,7 +474,7 @@ void stop(int timeout, TimeUnit timeUnit) {

for (SharedTorrent torrent : this.torrentsStorage.activeTorrents()) {
logger.trace("try close torrent {}", torrent);
torrent.close();
torrent.closeFully();
if (torrent.isFinished()) {
torrent.setClientState(ClientState.DONE);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ private void hashSingleThread() {
}

public synchronized void close() {
logger.trace("Closing torrent", myTorrentMetadata.getDirectoryName());
try {
this.pieceStorage.close();
isFileChannelOpen = false;
} catch (IOException ioe) {
logger.error("Error closing torrent byte storage: {}",
ioe.getMessage());
}
}

public synchronized void closeFully() {
logger.trace("Closing torrent", myTorrentMetadata.getDirectoryName());
try {
this.pieceStorage.closeFully();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Pair<SharedTorrent, LoadedTorrent> remove(String hash) {
}
}
if (result.first() != null) {
result.first().close();
result.first().closeFully();
}
return result;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public void clear() {
readWriteLock.writeLock().unlock();
}
for (SharedTorrent sharedTorrent : sharedTorrents) {
sharedTorrent.close();
sharedTorrent.closeFully();
}
for (LoadedTorrent loadedTorrent : loadedTorrents) {
try {
Expand Down

0 comments on commit 1b6167c

Please sign in to comment.