diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-12-25 13:03:38 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-12-25 13:03:38 -0800 |
commit | fa7631c85f6672773a2a07b0c921f29eddc1897a (patch) | |
tree | b4731e898ca85151393742fd4953044c2360c57c /src/github | |
parent | a33ac5f4e1bb59c2b2a394e22925f22fa4de40e3 (diff) | |
download | dsub-fa7631c85f6672773a2a07b0c921f29eddc1897a.tar.gz dsub-fa7631c85f6672773a2a07b0c921f29eddc1897a.tar.bz2 dsub-fa7631c85f6672773a2a07b0c921f29eddc1897a.zip |
Added a function for unpinning a song
Diffstat (limited to 'src/github')
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; |