Bug 67392 - feature request: save playlist changes immediately instead of program quit
Summary: feature request: save playlist changes immediately instead of program quit
Status: RESOLVED FIXED
Alias: None
Product: juk
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Scott Wheeler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-06 11:29 UTC by Simonics Zsolt
Modified: 2004-09-06 00:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simonics Zsolt 2003-11-06 11:29:18 UTC
Version:           2.0beta1 (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc (GCC) 3.3.2 20031022 (Gentoo Linux 3.3.2-r2, propolice) -mcpu=athlon-xp -O2 -pipe
OS:          Linux

It's a very good software, I have only one problem with it so far: I arranged thousands of mp3's into many playlists, that was 2-3 hours of "work", but before the last touches, juk has quit with Segfault. When I restarted it, sadly find out that my playlists are gone, it doesn't remember anything from the last few hours of work. It's would be nice to save every playlist modifications immediately, not just when quitting, to precede some heavy hair loss. Well, not having segfaults would be nice also :)
Thank you for your work, and please excuse me for my horrible English.
Comment 1 min 2004-04-29 00:41:50 UTC
really, it's common to quit the desktop without closing apps running in the system tray - and playlists are gone.
Comment 2 Jared Thirsk 2004-08-26 01:33:36 UTC
Hear hear to this...I've lost several hours of work as well.  
Comment 3 Michael Pyne 2004-08-29 01:59:23 UTC
CVS commit by mpyne: 

Fix bug 67392 (save playlist changes immediately), by auto-saving the playlists every 10 minutes.

Backport will follow.

CCMAIL:67392@bugs.kde.org


  M +20 -0     playlistbox.cpp   1.122
  M +1 -0      playlistbox.h   1.68


--- kdemultimedia/juk/playlistbox.h  #1.67:1.68
@@ -106,4 +106,5 @@ private slots:
     void slotSetViewMode(int index);
     void slotPlaylistDestroyed(Playlist*);
+    void slotSavePlaylists();
 
     void slotAddItem(const QString &tag, unsigned column);

--- kdemultimedia/juk/playlistbox.cpp  #1.121:1.122
@@ -24,4 +24,5 @@
 #include <qpainter.h>
 #include <qwidgetstack.h>
+#include <qtimer.h>
 
 #include "playlistbox.h"
@@ -144,4 +145,7 @@ PlaylistBox::PlaylistBox(QWidget *parent
     QTimer::singleShot(0, object(), SLOT(slotScanFolders()));
     enableDirWatch(true);
+
+    // Auto-save playlists after 10 minutes
+    QTimer::singleShot(600000, this, SLOT(slotSavePlaylists()));
 }
 
@@ -338,4 +342,20 @@ void PlaylistBox::slotPlaylistDestroyed(
 }
 
+void PlaylistBox::slotSavePlaylists()
+{
+    kdDebug(65432) << "Auto-saving playlists.\n";
+
+    PlaylistList l;
+    CollectionList *collection = CollectionList::instance();
+    for(QListViewItem *i = firstChild(); i; i = i->nextSibling()) {
+        Item *item = static_cast<Item *>(i);
+        if(item->playlist() && item->playlist() != collection)
+            l.append(item->playlist());
+    }
+
+    Cache::savePlaylists(l);
+    QTimer::singleShot(600000, this, SLOT(slotSavePlaylists()));
+}
+
 // For the following two function calls, we can forward the slot*Item calls
 // to the tree view mode as long as it has already been setup, whether or


Comment 4 Michael Pyne 2004-08-29 02:09:48 UTC
CVS commit by mpyne: 

Backport fix for bug 67392 (save playlist changes immediately) to KDE 3.3.

The bug is misnamed:  Data-loss is a bug, not an RFE. ;-)  In this case, data loss would occur if JuK crashed, reverting all of your playlists to the way they were when JuK started.

The fix works by auto-saving every 10 minutes in order to avoid thrashing the hard drive with every change.

CCMAIL:67392-done@bugs.kde.org


  M +20 -0     playlistbox.cpp   1.116.2.2
  M +1 -0      playlistbox.h   1.66.2.1


--- kdemultimedia/juk/playlistbox.h  #1.66:1.66.2.1
@@ -105,4 +105,5 @@ private slots:
     void slotSetViewMode(int index);
     void slotPlaylistDestroyed(Playlist*);
+    void slotSavePlaylists();
 
     void slotAddItem(const QString &tag, unsigned column);

--- kdemultimedia/juk/playlistbox.cpp  #1.116.2.1:1.116.2.2
@@ -24,4 +24,5 @@
 #include <qpainter.h>
 #include <qwidgetstack.h>
+#include <qtimer.h>
 
 #include "playlistbox.h"
@@ -142,4 +143,7 @@ PlaylistBox::PlaylistBox(QWidget *parent
 
     QTimer::singleShot(0, object(), SLOT(slotScanFolders()));
+
+    // Auto-save playlists after 10 minutes
+    QTimer::singleShot(30000, this, SLOT(slotSavePlaylists()));
 }
 
@@ -325,4 +329,20 @@ void PlaylistBox::slotPlaylistDestroyed(
 }
 
+void PlaylistBox::slotSavePlaylists()
+{
+    kdDebug(65432) << "Auto-saving playlists.\n";
+
+    PlaylistList l;
+    CollectionList *collection = CollectionList::instance();
+    for(QListViewItem *i = firstChild(); i; i = i->nextSibling()) {
+       Item *item = static_cast<Item *>(i);
+       if(item->playlist() && item->playlist() != collection)
+           l.append(item->playlist());
+    }
+
+    Cache::savePlaylists(l);
+    QTimer::singleShot(600000, this, SLOT(slotSavePlaylists()));
+}
+
 // For the following two function calls, we can forward the slot*Item calls
 // to the tree view mode as long as it has already been setup, whether or


Comment 5 Icekiss 2004-09-05 00:00:34 UTC
What exactly would the problem be with saving the single changes?
As far as I know, the Linux kernel caches them anyway, before it writes them to the disk. There is a reason for the "flush" command after all ;-)
And I think the changed files would be safer in the kernel cache. That way, if juk crashes, nothing is lost. If the kernel crashes, all is lost anyway...

Just a suggestion.
Thank you for working on juk :-)
Comment 6 Scott Wheeler 2004-09-05 01:02:28 UTC
To do something like that would require significantly restructuring the way that the cache is organized as it would need to be a "sparse" file and even then there are problems with such.

Just to put things in perspective saving the cache takes several seconds.  It's not something you want to repeat a lot.
Comment 7 Icekiss 2004-09-05 15:20:54 UTC
Well, I did not know a playlist file was so big it took several seconds to move it from one chache to another...
But hey, I have not looked into the source code of juk. So I have no idea how it does those things anyway.
I just saw the phrase "thrashing the hard drive", remembered that that should not be a problem, and pointed it out in case it would allow for a better solution.
If that is not feasable due to the way juk works: Oh well, nothing more lost than a bit of thought and a few minutes of writing time. :-)
Comment 8 Michael Pyne 2004-09-06 00:02:45 UTC
> ------- Additional Comments From Icekiss gmx at  2004-09-05 15:20 -------
> Well, I did not know a playlist file was so big it took several seconds to
> move it from one chache to another.

The problem is that there is only one cache, and it includes your entire 
Collection List.

If you'd like to save a separate copy of a playlist, there is always the File 
-> Save option that you can use.  I was going to add that before I realized 
it had already been implemented. :-/