Bug 27581 - non existing files remain in recent-files list
Summary: non existing files remain in recent-files list
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Stephan Kulow
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-06-22 21:03 UTC by allabos
Modified: 2006-01-24 17:29 UTC (History)
1 user (show)

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 allabos 2001-06-22 20:52:46 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kword
Version:           KDE 2.2.0 CVS/CVSup/Snapshot
Severity:          normal
Installed from:    Compiled sources
Compiler:          Not Specified
OS:                Linux
OS/Compiler notes: Not Specified

Hi David/Werner

As discussed on the koffice list however I
make a bug report so it will not be "forgotten"

> > > > > 3) Just discovered that when the file does not exist (see 1) (when
> > > > > using the open recent file dialog) the user can't press "ok". 
> > > > > Perfect but: shouldn't the file be removed from the open recent
> > > > > file list in this case?
> > > >
> > > > (Werner ?)
> > > > I think the idea is that we don't want to check all the files
> > > > initially (too slow) and we can't remove the file once you select it
> > > > either (too "jumpy").
>
> Hmmm... well it would be possible but it either is a pain
> to write or a pain to use. Just imagine you have some "recent
> files" on your favourite ftp server and everytime you start
> up KWord we start to check all those files. If we do it in a
> synchronous way you'll have to wait minutes to start KWord
> if we don't wait for the results you still would get invalid
> items.
>
> One solution which should be quite okay is that we delete the
> entry of any non existant file you select once. We have to
> check those files anyway and then we could remove them from
> the config file if it's not available anymore. Okay?
>
> Ciao
> Werner

(Submitted via bugs.kde.org)
Comment 1 David Preece 2001-08-30 03:14:57 UTC
Hi

I have a reference to a file in my "Window" menu on Kdevelop (1.4.1 on KDE 
2.1.1) and the file is no longer there. Since it has the same filename but 
different location to a file that I am using I ocasionally click on it to be 
told the file is not there.

Surely better to remove the menu entry when this happens?

Ta
Dave
Comment 2 Brad Hards 2004-06-15 13:46:11 UTC
The second reporter identified the problem in KDevelop, so this isn't strictly a KOffice problem, but a broader KDE issue.
Comment 3 Brad Hards 2004-06-15 13:50:41 UTC
Maybe it would be possible to file off some kind of minimal KIO:stat() per URL inside KRecentFilesAction::loadEntries(), and delete things from the list if the stat() says it doesn't exist. That would at least deal with the most common case.

I think most people would be willing to tolerate the system not realising that they had deleted a file if it was during that session.
Comment 4 Jordi Polo 2005-05-06 21:45:03 UTC
The code is pretty trivial:  
The svn diff:

Index: kactionclasses.cpp
===================================================================
--- kactionclasses.cpp  (revisión: 409943)
+++ kactionclasses.cpp  (copia de trabajo)
@@ -34,6 +34,7 @@
 #include <qobjectlist.h>
 #include <qwhatsthis.h>
 #include <qtimer.h>
+#include <qfile.h>

 #include <dcopclient.h>
 #include <dcopref.h>
@@ -1119,7 +1120,7 @@
     QString     value;
     QString     oldGroup;
     QStringList lst;
-
+
     oldGroup = config->group();

     if (groupname.isEmpty())
@@ -1132,8 +1133,12 @@
         key = QString( "File%1" ).arg( i );
         value = config->readPathEntry( key );

-        if (!value.isNull())
+        if (!value.isNull())
+        {
+           KURL addr(value);
+           if( !addr.isLocalFile() || QFile(addr.path()).exists())
             lst.append( value );
+        }
     }



I've tested it and works ok.
Comment 5 Thomas Braxton 2006-01-24 17:29:45 UTC
SVN commit 502014 by braxton:

Don't restore files to recent files list that don't exist anymore.
Same for KURLComboBox.

based on a patch by Jordi Polo <mumismo@wanadoo.es>

BUG: 27581

 M  +6 -0      kdeui/kactionclasses.cpp  
 M  +6 -0      kio/kfile/kurlcombobox.cpp  


--- branches/KDE/3.5/kdelibs/kdeui/kactionclasses.cpp #502013:502014
@@ -34,6 +34,7 @@
 #include <qobjectlist.h>
 #include <qwhatsthis.h>
 #include <qtimer.h>
+#include <qfile.h>
 
 #include <dcopclient.h>
 #include <dcopref.h>
@@ -1187,6 +1188,11 @@
         key = QString( "File%1" ).arg( i );
         value = config->readPathEntry( key );
         url = KURL::fromPathOrURL( value );
+
+        // Don't restore if file doesn't exist anymore
+        if (url.isLocalFile() && !QFile(url.path()).exists())
+          continue;
+
         nameKey = QString( "Name%1" ).arg( i );
         nameValue = config->readPathEntry( nameKey, url.fileName() );
         title = nameValue + " [" + value + "]";
--- branches/KDE/3.5/kdelibs/kio/kfile/kurlcombobox.cpp #502013:502014
@@ -180,6 +180,12 @@
         }
         u = KURL::fromPathOrURL( *it );
 
+        // Don't restore if file doesn't exist anymore
+        if (u.isLocalFile() && !QFile(u.path()).exists()) {
+            ++it; 
+            continue;
+        }
+
         item = new KURLComboItem;
         item->url = u;
         item->pixmap = getPixmap( u );