aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005/dsub/service/DownloadFile.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/github/daneren2005/dsub/service/DownloadFile.java')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadFile.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java
index 6ac6e90e..6ded4343 100644
--- a/src/github/daneren2005/dsub/service/DownloadFile.java
+++ b/src/github/daneren2005/dsub/service/DownloadFile.java
@@ -277,9 +277,8 @@ public class DownloadFile implements BufferFile {
public void unpin() {
if (saveFile.exists()) {
// Delete old store entry before renaming to pinned file
- deleteFromStore();
saveFile.renameTo(completeFile);
- saveToStore();
+ renameInStore(saveFile, completeFile);
}
}
@@ -313,9 +312,8 @@ public class DownloadFile implements BufferFile {
public void setPlaying(boolean isPlaying) {
try {
if(saveWhenDone && !isPlaying) {
- deleteFromStore();
Util.renameFile(completeFile, saveFile);
- saveToStore();
+ renameInStore(completeFile, saveFile);
saveWhenDone = false;
} else if(completeWhenDone && !isPlaying) {
if(save) {
@@ -361,6 +359,13 @@ public class DownloadFile implements BufferFile {
}
}
}
+ private void renameInStore(File start, File end) {
+ try {
+ mediaStoreService.renameInMediaStore(start, end);
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to rename in store", e);
+ }
+ }
@Override
public String toString() {
@@ -401,9 +406,8 @@ public class DownloadFile implements BufferFile {
if(isPlaying) {
saveWhenDone = true;
} else {
- deleteFromStore();
Util.renameFile(completeFile, saveFile);
- DownloadFile.this.saveToStore();
+ renameInStore(completeFile, saveFile);
}
} else {
Log.i(TAG, completeFile + " already exists. Skipping.");