aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-12-25 13:03:38 -0800
committerScott Jackson <daneren2005@gmail.com>2013-12-25 13:03:38 -0800
commitfa7631c85f6672773a2a07b0c921f29eddc1897a (patch)
treeb4731e898ca85151393742fd4953044c2360c57c /src
parenta33ac5f4e1bb59c2b2a394e22925f22fa4de40e3 (diff)
downloaddsub-fa7631c85f6672773a2a07b0c921f29eddc1897a.tar.gz
dsub-fa7631c85f6672773a2a07b0c921f29eddc1897a.tar.bz2
dsub-fa7631c85f6672773a2a07b0c921f29eddc1897a.zip
Added a function for unpinning a song
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java10
-rw-r--r--src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java9
-rw-r--r--src/github/daneren2005/dsub/util/FileUtil.java10
3 files changed, 12 insertions, 17 deletions
diff --git a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java
index b3f605e5..a1b20f73 100644
--- a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java
@@ -103,15 +103,7 @@ public class PlaylistSyncAdapter extends SubsonicSyncAdapter {
if(origPathList.size() > 0) {
for(String path: origPathList) {
File saveFile = new File(path);
-
- // Unpin file, rename to .complete
- File completeFile = new File(saveFile.getParent(), FileUtil.getBaseName(saveFile.getName()) +
- ".complete." + FileUtil.getExtension(saveFile.getName()));
-
- if(!saveFile.renameTo(completeFile)) {
- Log.w(TAG, "Failed to rename " + path + " to " + completeFile.getPath());
- }
-
+ FileUtil.unpinSong(saveFile);
cachedPlaylist.synced.remove(path);
}
diff --git a/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java
index a363a470..a23fa63f 100644
--- a/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java
@@ -65,14 +65,7 @@ public class StarredSyncAdapter extends SubsonicSyncAdapter {
for(String path: oldSyncedList) {
File saveFile = new File(path);
-
- // Unpin file, rename to .complete
- File completeFile = new File(saveFile.getParent(), FileUtil.getBaseName(saveFile.getName()) +
- ".complete." + FileUtil.getExtension(saveFile.getName()));
-
- if(!saveFile.renameTo(completeFile)) {
- Log.w(TAG, "Failed to rename " + path + " to " + completeFile.getPath());
- }
+ FileUtil.unpinSong(saveFile);
}
SyncUtil.setSyncedStarred(syncedList, context, instance);
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java
index 3adf3ad4..57c21e98 100644
--- a/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/src/github/daneren2005/dsub/util/FileUtil.java
@@ -242,6 +242,16 @@ public class FileUtil {
}
}
+ public static void unpinSong(File saveFile) {
+ // Unpin file, rename to .complete
+ File completeFile = new File(saveFile.getParent(), FileUtil.getBaseName(saveFile.getName()) +
+ ".complete." + FileUtil.getExtension(saveFile.getName()));
+
+ if(!saveFile.renameTo(completeFile)) {
+ Log.w(TAG, "Failed to rename " + saveFile + " to " + completeFile);
+ }
+ }
+
public static boolean ensureDirectoryExistsAndIsReadWritable(File dir) {
if (dir == null) {
return false;