Bug 119201 - Sometimes DigiKam fails to show newly downloaded photos (exemple found for Bug 119073: wish list rescan option)
Summary: Sometimes DigiKam fails to show newly downloaded photos (exemple found for Bu...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Import-History (show other bugs)
Version: 0.8.0
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-29 21:59 UTC by Tung NGUYEN
Modified: 2022-01-07 05:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 0.9.0


Attachments
/home/yourusername/camera/Photo 003.jpg (730.39 KB, image/jpeg)
2005-12-29 22:01 UTC, Tung NGUYEN
Details
proposed patch (3.25 KB, patch)
2005-12-30 01:36 UTC, Tom Albers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tung NGUYEN 2005-12-29 21:59:56 UTC
Version:           0.8.0 (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources
OS:                Linux

Summary of Bug 119073: wish list rescan option:

>>Occasional digikam fails to show newly downloaded photos in the >>directory listing. The easiest way to get them to show up is to close >>digikam then it will automatically rescan when it is reopened. 
>> Please include a 'rescan' menu item so that the database can be >>updated without having to restart digikam.
-----------------------------------------------------------------------

Tom,

I have the same problem with my camera in USB mass storage mode and I have found a simple exemple I can always reproduce. I hope you can reproduce it too:

1) Create an empty folder /home/yourusername/camera.

2) Download "Photo 003.jpg" attached to this bugreport and place it in /home/yourusername/camera.

3) Run Digikam 0.8.0 and point it to an empty Album library path.

4) Now, add a "Mounted Camera" with "Camera Mount Path=/home/yourusername/camera" (we simulate here my USB mass storage camera).

5) Download "Photo 003.jpg" with the option "Download photos into automatically created date-based sub-albums of destination album" (choose "My Albums" as destination album).

6) Now, the folder "2005-07-17" containing "Photo 003.jpg" is created in "My Albums" but does not display "Photo 003.jpg" thumbnail.

7) Restarting DigiKam solves the problem.

---
Tung.
Comment 1 Tung NGUYEN 2005-12-29 22:01:55 UTC
Created attachment 14071 [details]
/home/yourusername/camera/Photo 003.jpg
Comment 2 Tom Albers 2005-12-29 22:24:39 UTC
Okido, confirmed. Looks like new folders created by the camera dialog are not picked up.
Comment 3 Tom Albers 2005-12-30 01:36:41 UTC
Created attachment 14073 [details]
proposed patch

Tung, attached a patch for the problem: 
    When a directory is created, a watch is put on it to spot new files
    but it can occur that the file is copied there before the watch is
    completely setup. That is why as an extra safeguard run scanlib
    over the folders we used when the cameragui is closed.

Could you test it for me?
Comment 4 Tung NGUYEN 2005-12-31 13:17:22 UTC
Tom,

I have to read some doc on how to merge a patch... :-)

Promised, I will test it for you as soon as possible.
Comment 5 Tom Albers 2005-12-31 13:32:25 UTC
Tung, if you have our unpacked tarball, go into the digikam folder and apply this patch with: patch -p0 < downloaded file

If it complains it can not find the file, try -p1

If it is ok, it tells you that it is applied succesfully, after that you can do make and make install as usual.
Comment 6 Tung NGUYEN 2006-01-02 19:33:57 UTC
Tom,

I have tested your patch on DigiKam 0.8.0 tarball, it works fine. Thank you. You can close this bug report.

---
Tung.
Comment 7 Tom Albers 2006-01-02 21:20:41 UTC
SVN commit 493646 by toma:

Fix for the camergui.
When a directory is created, a watch is put on it to spot new files 
but it can occur that the file is copied there before the watch is 
completely setup. That is why as an extra safeguard run scanlib 
over the folders we used when the cameragui is closed.
BUG:119201
 



 M  +5 -0      digikam/scanlib.cpp  
 M  +7 -0      digikam/scanlib.h  
 M  +20 -2     utilities/cameragui/cameraui.cpp  
 M  +1 -0      utilities/cameragui/cameraui.h  


--- trunk/extragear/graphics/digikam/digikam/scanlib.cpp #493645:493646
@@ -150,6 +150,11 @@
     }
 }
 
+void ScanLib::findMissingItems(const QString &path)
+{
+    allFiles(path);
+}
+
 void ScanLib::findMissingItems()
 {
     QString albumPath = AlbumManager::instance()->getLibraryPath();
--- trunk/extragear/graphics/digikam/digikam/scanlib.h #493645:493646
@@ -71,6 +71,13 @@
     */
     void findMissingItems();
 
+    
+    /**
+     * This calls allFiles with a given path.
+     * @param path the path to scan.
+     */
+    void findMissingItems(const QString &path);
+            
     /** 
      * This queries the db for items that have no date
      * for each item found, storeItemInDatabase is called.
--- trunk/extragear/graphics/digikam/utilities/cameragui/cameraui.cpp #493645:493646
@@ -46,6 +46,7 @@
 #include <kiconloader.h>
 #include <kpopupmenu.h>
 #include <khelpmenu.h>
+#include <kdebug.h>
 
 #include <kcalendarsystem.h>
 
@@ -67,6 +68,7 @@
 #include "cameraiconitem.h"
 #include "cameracontroller.h"
 #include "cameraui.h"
+#include "scanlib.h"
 
 CameraUI::CameraUI(QWidget* parent, const QString& title,
                    const QString& model, const QString& port,
@@ -269,12 +271,26 @@
 
 void CameraUI::closeEvent(QCloseEvent* e)
 {
+    // When a directory is created, a watch is put on it to spot new files
+    // but it can occur that the file is copied there before the watch is
+    // completely setup. That is why as an extra safeguard run scanlib
+    // over the folders we used. Bug: 119201
+    ScanLib sLib;
+    for (QStringList::iterator it = m_foldersToScan.begin(); 
+         it != m_foldersToScan.end(); ++it)
+    {
+        kdDebug() << "Scanning " << (*it) << endl;
+        sLib.findMissingItems( (*it) );
+    }
+    
+    //---------------------------------------------------
+
     if(!m_lastDestURL.isEmpty())
         emit signalLastDestination(m_lastDestURL);
 
     delete m_controller;
     saveSettings();
-    e->accept();    
+    e->accept();
 }
 
 
@@ -469,10 +485,12 @@
             }
 
             u.addPath(dirName);
+            m_foldersToScan.append(u.path());
             u.addPath(downloadName.isEmpty() ? name : downloadName);
         }
         else
         {
+            m_foldersToScan.append(u.path());
             u.addPath(downloadName.isEmpty() ? name : downloadName);
         }
         m_controller->download(folder, name, u.path(), autoRotate);
@@ -482,7 +500,7 @@
 
     if (total <= 0)
         return;
-
+    
     m_lastDestURL = url;            
     m_progress->setProgress(0);
     m_progress->setTotalSteps(total);
--- trunk/extragear/graphics/digikam/utilities/cameragui/cameraui.h #493645:493646
@@ -97,6 +97,7 @@
     CameraController* m_controller;
     
     KURL              m_lastDestURL;
+    QStringList       m_foldersToScan;
 
 private slots:
 
Comment 8 Tom Albers 2006-01-02 21:21:55 UTC
SVN commit 493648 by toma:

Backport of the fix for the camergui:
When a directory is created, a watch is put on it to spot new files 
but it can occur that the file is copied there before the watch is 
completely setup. That is why as an extra safeguard run scanlib 
over the folders we used when the cameragui is closed. 
CCBUG: 119201



 M  +5 -0      digikam/scanlib.cpp  
 M  +7 -0      digikam/scanlib.h  
 M  +20 -2     utilities/cameragui/cameraui.cpp  
 M  +1 -0      utilities/cameragui/cameraui.h  


--- branches/stable/extragear/graphics/digikam/digikam/scanlib.cpp #493647:493648
@@ -150,6 +150,11 @@
     }
 }
 
+void ScanLib::findMissingItems(const QString &path)
+{
+    allFiles(path);
+}
+
 void ScanLib::findMissingItems()
 {
     QString albumPath = AlbumManager::instance()->getLibraryPath();
--- branches/stable/extragear/graphics/digikam/digikam/scanlib.h #493647:493648
@@ -71,6 +71,13 @@
     */
     void findMissingItems();
 
+    
+    /**
+     * This calls allFiles with a given path.
+     * @param path the path to scan.
+     */
+    void findMissingItems(const QString &path);
+            
     /** 
      * This queries the db for items that have no date
      * for each item found, storeItemInDatabase is called.
--- branches/stable/extragear/graphics/digikam/utilities/cameragui/cameraui.cpp #493647:493648
@@ -46,6 +46,7 @@
 #include <kiconloader.h>
 #include <kpopupmenu.h>
 #include <khelpmenu.h>
+#include <kdebug.h>
 
 #include <kcalendarsystem.h>
 
@@ -67,6 +68,7 @@
 #include "cameraiconitem.h"
 #include "cameracontroller.h"
 #include "cameraui.h"
+#include "scanlib.h"
 
 CameraUI::CameraUI(QWidget* parent, const QString& title,
                    const QString& model, const QString& port,
@@ -269,12 +271,26 @@
 
 void CameraUI::closeEvent(QCloseEvent* e)
 {
+    // When a directory is created, a watch is put on it to spot new files
+    // but it can occur that the file is copied there before the watch is
+    // completely setup. That is why as an extra safeguard run scanlib
+    // over the folders we used. Bug: 119201
+    ScanLib sLib;
+    for (QStringList::iterator it = m_foldersToScan.begin(); 
+         it != m_foldersToScan.end(); ++it)
+    {
+        kdDebug() << "Scanning " << (*it) << endl;
+        sLib.findMissingItems( (*it) );
+    }
+    
+    //---------------------------------------------------
+
     if(!m_lastDestURL.isEmpty())
         emit signalLastDestination(m_lastDestURL);
 
     delete m_controller;
     saveSettings();
-    e->accept();    
+    e->accept();
 }
 
 
@@ -469,10 +485,12 @@
             }
 
             u.addPath(dirName);
+            m_foldersToScan.append(u.path());
             u.addPath(downloadName.isEmpty() ? name : downloadName);
         }
         else
         {
+            m_foldersToScan.append(u.path());
             u.addPath(downloadName.isEmpty() ? name : downloadName);
         }
         m_controller->download(folder, name, u.path(), autoRotate);
@@ -482,7 +500,7 @@
 
     if (total <= 0)
         return;
-
+    
     m_lastDestURL = url;            
     m_progress->setProgress(0);
     m_progress->setTotalSteps(total);
--- branches/stable/extragear/graphics/digikam/utilities/cameragui/cameraui.h #493647:493648
@@ -97,6 +97,7 @@
     CameraController* m_controller;
     
     KURL              m_lastDestURL;
+    QStringList       m_foldersToScan;
 
 private slots: