aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2018-01-10 17:31:34 -0800
committerScott Jackson <daneren2005@gmail.com>2018-01-10 17:31:34 -0800
commit8ae4446fc1679486ecf80110984a69a416e1fdcf (patch)
tree322ee3ed41bed3f1a53bf724280ae61f536987d1 /app/src/main/java/github
parent67a86d196c85ea6b132bf49ab1459b2096feb530 (diff)
downloaddsub-8ae4446fc1679486ecf80110984a69a416e1fdcf.tar.gz
dsub-8ae4446fc1679486ecf80110984a69a416e1fdcf.tar.bz2
dsub-8ae4446fc1679486ecf80110984a69a416e1fdcf.zip
Fixes #814: Limit undeletable files to ones we are playing soon or just played
Diffstat (limited to 'app/src/main/java/github')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java8
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java2
2 files changed, 9 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index 4b8d9db3..e1b3d0ae 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -1036,6 +1036,14 @@ public class DownloadService extends Service {
return temp;
}
+ public synchronized List<DownloadFile> getRecentDownloads() {
+ int from = Math.max(currentPlayingIndex - 10, 0);
+ int to = Math.min(currentPlayingIndex + 20, downloadList.size() - 1);
+ List<DownloadFile> temp = downloadList.subList(from, to);
+ temp.addAll(backgroundDownloadList);
+ return temp;
+ }
+
public List<DownloadFile> getBackgroundDownloads() {
return backgroundDownloadList;
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java b/app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java
index ac8fa72a..f160e176 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/CacheCleaner.java
@@ -151,7 +151,7 @@ public class CacheCleaner {
private Set<File> findUndeletableFiles() {
Set<File> undeletable = new HashSet<File>(5);
- for (DownloadFile downloadFile : downloadService.getDownloads()) {
+ for (DownloadFile downloadFile : downloadService.getRecentDownloads()) {
undeletable.add(downloadFile.getPartialFile());
undeletable.add(downloadFile.getCompleteFile());
}