Bug 99896

Summary: Copying images destroys file date
Product: [Applications] digikam Reporter: Johannes Stallkamp <jstallkamp>
Component: Database-ScanAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In: 8.0.0

Description Johannes Stallkamp 2005-02-21 00:24:46 UTC
Version:           digikam 0.7 (using KDE KDE 3.3.2)
OS:                Linux

Copying images between two albums "destroys" (i.e. does not properly set) the file date of the copy. Since Digikam uses the file's modifications date to sort images by date instead of the EXIF date, the copied file's modification date should be set according to the original image.
Comment 1 Renchi Raju 2005-02-21 05:37:25 UTC
CVS commit by pahlibar: 



when copying files over, set the file modification time to that of src file
BUG: 99896


  M +25 -0     digikamio.cpp   1.11


--- kdeextragear-3/digikam/kioslave/digikamio.cpp  #1.10:1.11
@@ -45,4 +45,5 @@ extern "C" 
 #include <sys/time.h>
 #include <time.h>
+#include <utime.h>
 #include <errno.h>
 #include <sqlite.h>
@@ -412,4 +413,16 @@ void kio_digikamioProtocol::copyInternal
                      .arg(oldDirID)
                      .arg(escapeString(src.fileName())) );
+
+            // also set the filetime to that of the original file
+            struct utimbuf t;
+            t.actime  = buff_src.st_atime;
+            t.modtime = buff_src.st_mtime;
+
+            if ( ::utime( _dest.data(), &t ) != 0 )
+            {
+                kdWarning() << k_funcinfo
+                            << "Failed to set datetime of destination file "
+                            << "to that of of original file" << endl;
+            }
         }
 
@@ -447,4 +460,16 @@ void kio_digikamioProtocol::copyInternal
             return;
         }
+
+        // also set the filetime to that of the original file
+        struct utimbuf t;
+        t.actime  = buff_src.st_atime;
+        t.modtime = buff_src.st_mtime;
+
+        if ( ::utime( _dest.data(), &t ) != 0 )
+        {
+            kdWarning() << k_funcinfo
+                        << "Failed to set datetime of destination file "
+                        << "to that of of original file" << endl;
+        }
     }
 }