diff options
Diffstat (limited to 'src/github/daneren2005')
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; |