summaryrefslogtreecommitdiff
path: root/plugins/gtkui
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-11-24 19:37:50 +0100
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-11-24 19:37:50 +0100
commitd5bf20dcf5ea8945b21c09f988f17e00d016c02c (patch)
treed44d178846d999f08c36ecdadecc86063a3ea720 /plugins/gtkui
parentd09c88507b436fae113c474b15f6a854ef57a830 (diff)
gtkui: remove_from_disk won't remove files from playlist if it can't delete them from disk
Diffstat (limited to 'plugins/gtkui')
-rw-r--r--plugins/gtkui/actionhandlers.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/plugins/gtkui/actionhandlers.c b/plugins/gtkui/actionhandlers.c
index b2923c2e..ade74348 100644
--- a/plugins/gtkui/actionhandlers.c
+++ b/plugins/gtkui/actionhandlers.c
@@ -38,6 +38,7 @@
#include "interface.h"
#include "trkproperties.h"
#include "callbacks.h"
+#include <sys/stat.h>
extern GtkWidget *mainwin;
extern DB_functions_t *deadbeef;
@@ -482,6 +483,19 @@ action_remove_from_playlist_handler (DB_plugin_action_t *act, int ctx) {
return 0;
}
+void
+delete_and_remove_track (const char *uri, ddb_playlist_t *plt, ddb_playItem_t *it) {
+ int res = unlink (uri);
+
+ // check if file exists
+ struct stat buf;
+ memset (&buf, 0, sizeof (buf));
+ int stat_res = stat (uri, &buf);
+ if (stat_res != 0) {
+ deadbeef->plt_remove_item (plt, it);
+ }
+}
+
gboolean
action_delete_from_disk_handler_cb (void *data) {
int ctx = (intptr_t)data;
@@ -508,9 +522,7 @@ action_delete_from_disk_handler_cb (void *data) {
while (it) {
const char *uri = deadbeef->pl_find_meta (it, ":URI");
if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (uri)) {
- if (!unlink (uri)) {
- deadbeef->plt_remove_item (plt, it);
- }
+ delete_and_remove_track (uri, plt, it);
}
DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
deadbeef->pl_item_unref (it);
@@ -524,9 +536,7 @@ action_delete_from_disk_handler_cb (void *data) {
while (it) {
const char *uri = deadbeef->pl_find_meta (it, ":URI");
if (deadbeef->is_local_file (uri)) {
- if (!unlink (uri)) {
- deadbeef->plt_remove_item (plt, it);
- }
+ delete_and_remove_track (uri, plt, it);
// FIXME: this dialog should allow something like "cancel" and "ignore all", then
// it will be usable
// else {
@@ -552,9 +562,7 @@ action_delete_from_disk_handler_cb (void *data) {
if (deadbeef->is_local_file (uri)) {
int idx = deadbeef->plt_get_item_idx (plt, it, PL_MAIN);
if (idx != -1) {
- if (!unlink (uri)) {
- deadbeef->plt_remove_item (plt, it);
- }
+ delete_and_remove_track (uri, plt, it);
}
}
deadbeef->pl_item_unref (it);